Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37716522
en ru br
Репозитории ALT
5.1: 2.4.27-alt11
4.1: 2.4.27-alt11
4.0: 2.4.27-alt10
3.0: 2.4.27-alt4
www.altlinux.org/Changes

Группа :: Система/Ядро и оборудование
Пакет: modutils

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: modutils-2.4.25-alt-include.patch
Скачать


--- modutils-2.4.25/util/config.c.orig	2003-08-09 18:20:57 +0400
+++ modutils-2.4.25/util/config.c	2003-08-09 19:26:55 +0400
@@ -54,6 +54,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include <ctype.h>
 #include <sys/stat.h>
 #include <signal.h>
@@ -187,8 +188,7 @@ static int need_update (const char *forc
 		gen_file[i].mtime = tmp.st_mtime;
 	}
 
-	if (stat ("/etc/modules.conf", &tmp) &&
-	    stat ("/etc/conf.modules", &tmp))
+	if (stat (config_file, &tmp))
 		return 1;
 
 	for (i = 0; i < gen_file_count; ++i) {
@@ -474,6 +474,8 @@ static int gen_file_check(struct gen_fil
 	return(ret);
 }
 
+static int do_read_x(int all, char *force_ver, char *base_dir, char *conf_file, int depth);
+
 /*
  *	Read the configuration file.
  *	If parameter "all" == 0 then ignore everything except path info
@@ -822,9 +824,12 @@ static int do_read(int all, char *force_
 
 	if (fin) {
 		struct stat statbuf1, statbuf2;
-		if (fstat(fileno(fin), &statbuf1) == 0)
+		if (fstat(fileno(fin), &statbuf1) == 0 && statbuf1.st_mtime >= config_mtime) {
+			/* Save name and mtime actually used */
 			config_mtime = statbuf1.st_mtime;
-		config_file = xstrdup(conf_file);	/* Save name actually used */
+			free(config_file);
+			config_file = xstrdup(conf_file);
+		}
 		if (!conf_file_specified &&
 		    stat(ETC_MODULES_CONF, &statbuf1) == 0 &&
 		    stat(old_name, &statbuf2) == 0) {
@@ -1105,17 +1110,17 @@ static int do_read(int all, char *force_
 
 				if (g.pathc>0) {
 					for ( ; inc_idx<g.pathc; inc_idx++) {
-						if (!do_read(all, version, base_dir, g.pathv[inc_idx], depth+1))
+						if (!do_read_x(all, version, base_dir, g.pathv[inc_idx], depth+1))
 							one_err = 0;
 						else
-							error("include %s failed\n", g.pathv[inc_idx]);
+							error("include %s failed", g.pathv[inc_idx]);
 					}
 				}
 				else {
-					if (!do_read(all, version, base_dir, g.pathc ? g.pathv[0] : arg, depth+1))
+					if (!do_read_x(all, version, base_dir, arg, depth+1))
 						one_err = 0;
 					else
-						error("include %s failed\n", arg);
+						error("include %s failed", arg);
 				}
 
 				arg = arg2;
@@ -1391,6 +1396,69 @@ static int do_read(int all, char *force_
 	return ret;
 }
 
+static int do_read_x(int all, char *force_ver, char *base_dir, char *conf_file, int depth)
+{
+	GLOB_LIST g;
+	int fd;
+	int i, rc = 0;
+	unsigned len = strlen(conf_file);
+	if (len < 1 || conf_file[len-1] != '/')
+		return do_read(all, force_ver, base_dir, conf_file, depth);
+
+	if ((fd = open(".", O_RDONLY | O_DIRECTORY)) < 0) {
+		error("Can't open current directory");
+		return -1;
+	}
+	if (chdir(conf_file)) {
+		error("Can't chdir to %s", conf_file);
+		close(fd);
+		return -1;
+	}
+
+	rc = meta_expand("*", &g, NULL, force_ver, ME_GLOB);
+
+	fchdir(fd);
+	close(fd);
+	fd = -1;
+
+	if (rc) {
+		error("meta_expand %s/* failed", conf_file);
+		return -1;
+	}
+
+	for (i = 0; i < g.pathc; ++i) {
+		struct stat st;
+		const char *p;
+		char *fname;
+
+		for (p = g.pathv[i]; *p; ++p)
+			if (!isalnum(*p) && ('_' != *p) && ('-' != *p))
+				break;
+		if (*p)
+			continue;
+
+		fname = xmalloc(len + strlen(g.pathv[i]) + 1);
+		strcpy(fname, conf_file);
+		strcpy(fname + len, g.pathv[i]);
+		
+		if (stat(fname, &st)) {
+			free(fname);
+			continue;
+		}
+		if (!S_ISREG(st.st_mode)) {
+			free(fname);
+			continue;
+		}
+
+		if ((rc = do_read(all, force_ver, base_dir, fname, depth + 1)))
+			error("include %s failed", fname);
+
+		free(fname);
+	}
+
+	return rc;
+}
+
 int config_read(int all, char *force_ver, char *base_dir, char *conf_file)
 {
 	int r;
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin