]> git.pld-linux.org Git - packages/arpd.git/blame - arpd-uid.patch
- pl fixes
[packages/arpd.git] / arpd-uid.patch
CommitLineData
2d9dce24
PG
1--- ./arpd.c.orig Tue Aug 21 13:26:27 2001
2+++ ./arpd.c Fri Aug 24 12:28:12 2001
3@@ -21,6 +21,7 @@
4 #include <sys/socket.h>
5 #include <netinet/in.h>
6 #include <arpa/inet.h>
7+#include <pwd.h>
8
9 #ifdef DEBUG
10 static void arpd_print(char*, struct arpd_request*);
11@@ -28,10 +29,25 @@
12 #define arpd_print(x,y)
13 #endif
14
15-/* these shouldn't change for ipv4 */
16+/* these shouldn't change for ipv4 */
17 #define ARPD_TRIEWIDTH 256
7f8abf2f 18 #define ARPD_TRIEDEPTH 16
2d9dce24
PG
19
20+/* usage string */
21+static char* usage=
08d7125f
JB
22+"ARP daemon - version 1.0.2 - PLD modified\n\
23+Usage: arpd -u user\n\
24+-u user, which you want to run this deamon\n\
25+\n\
26+The user you will take must have RW access to /dev/arpd.\n\
27+If you don't know what to choice take root.\n\
28+\n\
2d9dce24
PG
29+";
30+
31+void show_usage() {
32+ fprintf(stdout,usage);
33+}
34+
35 union arpd_triedef
36 {
37 union arpd_triedef * hash;
38@@ -54,7 +70,34 @@
39 struct arpd_request req;
40 struct arpd_request *rep;
41
42+ char* cmd = NULL;
43+ unsigned int uid_num = 0;
44+ struct passwd *pw;
45+ char *account;
46+
47+if ((argc != 3)) {
48+ fprintf(stdout,"Invalid option.\n");
49+ show_usage();
50+ exit(1);
51+ }
52+else {
53 #ifndef DEBUG
54+ cmd = argv[1];
55+
56+ if (strcasecmp(cmd, "-u") == 0) {
57+ account=argv[2];
58+ pw=getpwnam(account);
59+ if (!pw) {
60+ fprintf(stderr,"Unknown account.\n");
61+ exit(1);
62+ }
63+ uid_num=pw->pw_uid;
64+ }
65+ else {
66+ fprintf(stderr,"Invalid option.\n");
67+ show_usage();
68+ exit(1);
69+ }
70 if (fork())
71 exit(0);
72
73@@ -72,14 +115,19 @@
74 if (fd > 2)
75 close(fd);
76 }
77- setsid();
78+ /* setsid(); */
79+
80 #endif
24546bce
PG
81
82 openlog ("arpd", LOG_PID | LOG_CONS, LOG_DAEMON);
83
84- syslog(LOG_NOTICE, "Initializing, version %s\n", ARPD_VERSION);
2d9dce24 85+ syslog(LOG_NOTICE, "Initializing, modified version %s\n", ARPD_VERSION);
24546bce 86
2d9dce24
PG
87 fd = open("/dev/arpd", O_RDWR);
88+
89+ /* Set proper UID */
90+ setuid(uid_num);
91+
24546bce 92 if (fd < 0) {
2d9dce24 93 syslog(LOG_CRIT, "cannot open /dev/arpd: %m");
24546bce 94 exit(-1);
2d9dce24 95@@ -136,6 +184,7 @@
db46488d 96 }
2d9dce24
PG
97
98 return 0;
99+ }
100 }
101
102 static void arpd_update (struct arpd_request * entry)
This page took 0.062648 seconds and 4 git commands to generate.