Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37518657
en ru br
Репозитории ALT
S:1.8.0-alt1
5.1: 1.4.1-alt30
4.1: 1.4.1-alt28
4.0: 1.4.1-alt27
3.0: 1.4.1-alt20
www.altlinux.org/Changes

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

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

Патч: sysklogd-1.4.1-alt-funix_dir.patch
Скачать


diff -ur sysklogd-1.4.1~/syslogd.c sysklogd-1.4.1/syslogd.c
--- sysklogd-1.4.1~/syslogd.c	Sun Apr 14 23:38:09 2002
+++ sysklogd-1.4.1/syslogd.c	Mon Apr 15 01:05:25 2002
@@ -492,6 +492,8 @@
 #include <arpa/inet.h>
 #include <resolv.h>
 
+#include <error.h>
+#include <dirent.h>
 #include <pwd.h>
 #include <grp.h>
 
@@ -567,7 +569,7 @@
 #define MAXFUNIX	20
 
 int nfunix = 1;
-char *funixn[MAXFUNIX] = { _PATH_LOG };
+const char *funixn[MAXFUNIX] = { _PATH_LOG };
 int funix[MAXFUNIX] = { -1, };
 
 #ifdef UT_NAMESIZE
@@ -804,6 +806,76 @@
 	return 0;
 }
 
+char   *
+xstrdup (const char *s)
+{
+	char   *r = strdup (s);
+
+	if (!r)
+		error (1, errno, "strdup");
+	return r;
+}
+
+static void
+add_funix_name (const char *fname)
+{
+	unsigned i;
+
+	for (i = 0; i < MAXFUNIX; ++i)
+		if (!strcmp (fname, funixn[i]))
+			return;
+
+	if (nfunix < MAXFUNIX)
+		funixn[nfunix++] = fname;
+	else
+		error (0, 0, "out of descriptors, ignoring %s\n", fname);
+}
+
+static void
+add_funix_dir (const char *dname)
+{
+	DIR *dir;
+	struct dirent *entry;
+
+	if (chdir (dname))
+	{
+		error (0, errno, "chdir: %s", dname);
+		return;
+	}
+
+	if (!(dir = opendir (".")))
+	{
+		error (0, errno, "opendir: %s", dname);
+		chdir ("/");
+		return;
+	}
+
+	while ((entry = readdir (dir)))
+	{
+		struct stat st;
+
+		if (strchr (entry->d_name, '.'))
+			continue;
+
+		if (lstat (entry->d_name, &st))
+			continue;
+
+		if (S_ISLNK(st.st_mode))
+		{
+			char buf[MAXPATHLEN];
+			int n = readlink (entry->d_name, buf, sizeof(buf));
+			if ((n <= 0) || (n >= sizeof(buf)) || (buf[0] != '/'))
+				continue;
+			buf[n] = '\0';
+			add_funix_name (xstrdup (buf));
+		}
+	}
+
+	if (closedir (dir))
+		error (0, errno, "closedir: %s", dname);
+	chdir ("/");
+}
+
 int main(argc, argv)
 	int argc;
 	char **argv;
@@ -848,6 +920,7 @@
 	extern int optind;
 	extern char *optarg;
 	int maxfds;
+	const char *funix_dir = "/etc/syslog.d";
 
 #ifndef TESTING
 	chdir ("/");
@@ -857,13 +930,13 @@
 		funix[i]  = -1;
 	}
 
-	while ((ch = getopt(argc, argv, "a:dhf:i:j:l:m:np:rs:u:v")) != EOF)
+	while ((ch = getopt(argc, argv, "a:A:dhf:i:j:l:m:np:rs:u:v")) != EOF)
 		switch((char)ch) {
 		case 'a':
-			if (nfunix < MAXFUNIX)
-				funixn[nfunix++] = optarg;
-			else
-				fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
+			add_funix_name (optarg);
+			break;
+		case 'A':
+			funix_dir = optarg;
 			break;
 		case 'd':		/* debug */
 			Debug = 1;
@@ -930,6 +1003,8 @@
 		fputs("'-j' is only valid with '-u'", stderr);
 		exit(1);
 	}
+	if (funix_dir && *funix_dir)
+		add_funix_dir (funix_dir);
 #ifndef TESTING
 	if ( !(Debug || NoFork) )
 	{
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin