X-Git-Url: http://git.pld-linux.org/?p=packages%2Farpd.git;a=blobdiff_plain;f=arpd-uid.patch;h=0e4f7cb56a447c608810786b5443566da23c3533;hp=306e3994dc853ce4744a65a866f09bc76eac0107;hb=7875af3dbcf3a3c922069bd64d756cf9899b4ec1;hpb=06cb3366e3da4996c05189d16884e850dd97a9fd diff --git a/arpd-uid.patch b/arpd-uid.patch index 306e399..0e4f7cb 100644 --- a/arpd-uid.patch +++ b/arpd-uid.patch @@ -1,18 +1,102 @@ ---- ./arpd.c.orig Tue Jul 17 18:46:39 2001 -+++ ./arpd.c Fri Jul 27 20:32:06 2001 -@@ -74,11 +74,15 @@ +--- ./arpd.c.orig Tue Aug 21 13:26:27 2001 ++++ ./arpd.c Fri Aug 24 12:28:12 2001 +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #ifdef DEBUG + static void arpd_print(char*, struct arpd_request*); +@@ -28,10 +29,25 @@ + #define arpd_print(x,y) + #endif + +-/* these shouldn't change for ipv4 */ ++/* these shouldn't change for ipv4 */ + #define ARPD_TRIEWIDTH 256 + #define ARPD_TRIEDEPTH 8 + ++/* usage string */ ++static char* usage= ++"ARP daemon - version 1.0.2 - PLD modified ++Usage: arpd -u user ++-u user, which you want to run this deamon ++ ++The user you will take must have RW access to /dev/arpd. ++If you don't know what to choice take root. ++ ++"; ++ ++void show_usage() { ++ fprintf(stdout,usage); ++} ++ + union arpd_triedef + { + union arpd_triedef * hash; +@@ -54,7 +70,34 @@ + struct arpd_request req; + struct arpd_request *rep; + ++ char* cmd = NULL; ++ unsigned int uid_num = 0; ++ struct passwd *pw; ++ char *account; ++ ++if ((argc != 3)) { ++ fprintf(stdout,"Invalid option.\n"); ++ show_usage(); ++ exit(1); ++ } ++else { + #ifndef DEBUG ++ cmd = argv[1]; ++ ++ if (strcasecmp(cmd, "-u") == 0) { ++ account=argv[2]; ++ pw=getpwnam(account); ++ if (!pw) { ++ fprintf(stderr,"Unknown account.\n"); ++ exit(1); ++ } ++ uid_num=pw->pw_uid; ++ } ++ else { ++ fprintf(stderr,"Invalid option.\n"); ++ show_usage(); ++ exit(1); ++ } + if (fork()) + exit(0); + +@@ -72,14 +115,19 @@ + if (fd > 2) + close(fd); + } +- setsid(); ++ /* setsid(); */ ++ + #endif openlog ("arpd", LOG_PID | LOG_CONS, LOG_DAEMON); - syslog(LOG_NOTICE, "Initializing, version %s\n", ARPD_VERSION); -+ syslog(LOG_NOTICE, "Initializing, PLD-modified version %s\n", ARPD_VERSION); ++ syslog(LOG_NOTICE, "Initializing, modified version %s\n", ARPD_VERSION); - fd = open("/dev/arpd", O_RDWR); -+/* You need to have user UID=40 in your system. There is needed to make checking -+ * that "little" thing. */ -+ setuid(40); -+ + fd = open("/dev/arpd", O_RDWR); ++ ++ /* Set proper UID */ ++ setuid(uid_num); ++ if (fd < 0) { - syslog(LOG_CRIT, "cannot open /dev/arpd: %m"); + syslog(LOG_CRIT, "cannot open /dev/arpd: %m"); exit(-1); +@@ -136,6 +184,7 @@ } + + return 0; ++ } + } + + static void arpd_update (struct arpd_request * entry)