diff options
-rw-r--r-- | chpst.c | 31 | ||||
-rw-r--r-- | pathexec.h | 6 | ||||
-rw-r--r-- | pathexec_env.c | 8 | ||||
-rw-r--r-- | pathexec_run.c | 3 | ||||
-rw-r--r-- | prot.c | 7 | ||||
-rw-r--r-- | prot.h | 2 | ||||
-rw-r--r-- | sgetopt.c | 2 | ||||
-rw-r--r-- | sgetopt.h | 2 | ||||
-rw-r--r-- | subgetopt.c | 2 | ||||
-rw-r--r-- | subgetopt.h | 2 |
10 files changed, 35 insertions, 30 deletions
@@ -3,6 +3,7 @@ | |||
3 | #include <sys/time.h> | 3 | #include <sys/time.h> |
4 | #include <sys/resource.h> | 4 | #include <sys/resource.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #include <grp.h> | ||
6 | #include "sgetopt.h" | 7 | #include "sgetopt.h" |
7 | #include "error.h" | 8 | #include "error.h" |
8 | #include "strerr.h" | 9 | #include "strerr.h" |
@@ -40,7 +41,7 @@ void usage() { strerr_die4x(100, "usage: ", progname, USAGE_MAIN, "\n"); } | |||
40 | 41 | ||
41 | char *set_user =0; | 42 | char *set_user =0; |
42 | char *env_user =0; | 43 | char *env_user =0; |
43 | const char *argv0 =0; | 44 | char *argv0 =0; |
44 | const char *env_dir =0; | 45 | const char *env_dir =0; |
45 | unsigned int verbose =0; | 46 | unsigned int verbose =0; |
46 | unsigned int pgrp =0; | 47 | unsigned int pgrp =0; |
@@ -258,14 +259,14 @@ void slimit() { | |||
258 | } | 259 | } |
259 | 260 | ||
260 | /* argv[0] */ | 261 | /* argv[0] */ |
261 | void setuidgid(int, const char *const *); | 262 | void setuidgid(int, char *const *); |
262 | void envuidgid(int, const char *const *); | 263 | void envuidgid(int, char *const *); |
263 | void envdir(int, const char *const *); | 264 | void envdir(int, char *const *); |
264 | void pgrphack(int, const char *const *); | 265 | void pgrphack(int, char *const *); |
265 | void setlock(int, const char *const *); | 266 | void setlock(int, char *const *); |
266 | void softlimit(int, const char *const *); | 267 | void softlimit(int, char *const *); |
267 | 268 | ||
268 | int main(int argc, const char **argv) { | 269 | int main(int argc, char **argv) { |
269 | int opt; | 270 | int opt; |
270 | int i; | 271 | int i; |
271 | unsigned long ul; | 272 | unsigned long ul; |
@@ -366,7 +367,7 @@ int main(int argc, const char **argv) { | |||
366 | void setuidgid_usage() { | 367 | void setuidgid_usage() { |
367 | strerr_die4x(100, "usage: ", progname, USAGE_SETUIDGID, "\n"); | 368 | strerr_die4x(100, "usage: ", progname, USAGE_SETUIDGID, "\n"); |
368 | } | 369 | } |
369 | void setuidgid(int argc, const char *const *argv) { | 370 | void setuidgid(int argc, char *const *argv) { |
370 | const char *account; | 371 | const char *account; |
371 | 372 | ||
372 | if (! (account =*++argv)) setuidgid_usage(); | 373 | if (! (account =*++argv)) setuidgid_usage(); |
@@ -379,7 +380,7 @@ void setuidgid(int argc, const char *const *argv) { | |||
379 | void envuidgid_usage() { | 380 | void envuidgid_usage() { |
380 | strerr_die4x(100, "usage: ", progname, USAGE_ENVUIDGID, "\n"); | 381 | strerr_die4x(100, "usage: ", progname, USAGE_ENVUIDGID, "\n"); |
381 | } | 382 | } |
382 | void envuidgid(int argc, const char *const *argv) { | 383 | void envuidgid(int argc, char *const *argv) { |
383 | const char *account; | 384 | const char *account; |
384 | 385 | ||
385 | if (! (account =*++argv)) envuidgid_usage(); | 386 | if (! (account =*++argv)) envuidgid_usage(); |
@@ -392,7 +393,7 @@ void envuidgid(int argc, const char *const *argv) { | |||
392 | void envdir_usage() { | 393 | void envdir_usage() { |
393 | strerr_die4x(100, "usage: ", progname, USAGE_ENVDIR, "\n"); | 394 | strerr_die4x(100, "usage: ", progname, USAGE_ENVDIR, "\n"); |
394 | } | 395 | } |
395 | void envdir(int argc, const char *const *argv) { | 396 | void envdir(int argc, char *const *argv) { |
396 | const char *dir; | 397 | const char *dir; |
397 | 398 | ||
398 | if (! (dir =*++argv)) envdir_usage(); | 399 | if (! (dir =*++argv)) envdir_usage(); |
@@ -405,7 +406,7 @@ void envdir(int argc, const char *const *argv) { | |||
405 | void pgrphack_usage() { | 406 | void pgrphack_usage() { |
406 | strerr_die4x(100, "usage: ", progname, USAGE_PGRPHACK, "\n"); | 407 | strerr_die4x(100, "usage: ", progname, USAGE_PGRPHACK, "\n"); |
407 | } | 408 | } |
408 | void pgrphack(int argc, const char *const *argv) { | 409 | void pgrphack(int argc, char *const *argv) { |
409 | if (! *++argv) pgrphack_usage(); | 410 | if (! *++argv) pgrphack_usage(); |
410 | setsid(); | 411 | setsid(); |
411 | pathexec(argv); | 412 | pathexec(argv); |
@@ -415,7 +416,7 @@ void pgrphack(int argc, const char *const *argv) { | |||
415 | void setlock_usage() { | 416 | void setlock_usage() { |
416 | strerr_die4x(100, "usage: ", progname, USAGE_SETLOCK, "\n"); | 417 | strerr_die4x(100, "usage: ", progname, USAGE_SETLOCK, "\n"); |
417 | } | 418 | } |
418 | void setlock(int argc, const char *const *argv) { | 419 | void setlock(int argc, char *const *argv) { |
419 | int opt; | 420 | int opt; |
420 | unsigned int delay =0; | 421 | unsigned int delay =0; |
421 | unsigned int x =0; | 422 | unsigned int x =0; |
@@ -449,7 +450,7 @@ void getlarg(long *l) { | |||
449 | if (optarg[scan_ulong(optarg, &ul)]) usage(); | 450 | if (optarg[scan_ulong(optarg, &ul)]) usage(); |
450 | *l =ul; | 451 | *l =ul; |
451 | } | 452 | } |
452 | void softlimit(int argc, const char *const *argv) { | 453 | void softlimit(int argc, char *const *argv) { |
453 | int opt; | 454 | int opt; |
454 | 455 | ||
455 | while ((opt =getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof) | 456 | while ((opt =getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof) |
@@ -3,9 +3,9 @@ | |||
3 | #ifndef PATHEXEC_H | 3 | #ifndef PATHEXEC_H |
4 | #define PATHEXEC_H | 4 | #define PATHEXEC_H |
5 | 5 | ||
6 | extern void pathexec_run(const char *,const char * const *,const char * const *); | 6 | extern void pathexec_run(const char *, char *const *, char *const *); |
7 | extern int pathexec_env(const char *,const char *); | 7 | extern int pathexec_env(const char *,const char *); |
8 | extern void pathexec_env_run(const char *, const char * const *); | 8 | extern void pathexec_env_run(const char *, char *const *); |
9 | extern void pathexec(const char * const *); | 9 | extern void pathexec(char * const *); |
10 | 10 | ||
11 | #endif | 11 | #endif |
diff --git a/pathexec_env.c b/pathexec_env.c index 1305469..f873094 100644 --- a/pathexec_env.c +++ b/pathexec_env.c | |||
@@ -22,9 +22,9 @@ int pathexec_env(const char *s,const char *t) | |||
22 | return stralloc_cat(&plus,&tmp); | 22 | return stralloc_cat(&plus,&tmp); |
23 | } | 23 | } |
24 | 24 | ||
25 | void pathexec_env_run(const char *file, const char *const *argv) | 25 | void pathexec_env_run(const char *file, char *const *argv) |
26 | { | 26 | { |
27 | const char **e; | 27 | char **e; |
28 | unsigned int elen; | 28 | unsigned int elen; |
29 | unsigned int i; | 29 | unsigned int i; |
30 | unsigned int j; | 30 | unsigned int j; |
@@ -40,7 +40,7 @@ void pathexec_env_run(const char *file, const char *const *argv) | |||
40 | if (!plus.s[i]) | 40 | if (!plus.s[i]) |
41 | ++elen; | 41 | ++elen; |
42 | 42 | ||
43 | e = (const char **) alloc((elen + 1) * sizeof(char *)); | 43 | e = (char **) alloc((elen + 1) * sizeof(char *)); |
44 | if (!e) return; | 44 | if (!e) return; |
45 | 45 | ||
46 | elen = 0; | 46 | elen = 0; |
@@ -68,7 +68,7 @@ void pathexec_env_run(const char *file, const char *const *argv) | |||
68 | alloc_free(e); | 68 | alloc_free(e); |
69 | } | 69 | } |
70 | 70 | ||
71 | void pathexec(const char *const *argv) | 71 | void pathexec(char *const *argv) |
72 | { | 72 | { |
73 | return pathexec_env_run(*argv, argv); | 73 | return pathexec_env_run(*argv, argv); |
74 | } | 74 | } |
diff --git a/pathexec_run.c b/pathexec_run.c index 1770ac7..51f13ea 100644 --- a/pathexec_run.c +++ b/pathexec_run.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* Public domain. */ | 1 | /* Public domain. */ |
2 | 2 | ||
3 | #include <unistd.h> | ||
3 | #include "error.h" | 4 | #include "error.h" |
4 | #include "stralloc.h" | 5 | #include "stralloc.h" |
5 | #include "str.h" | 6 | #include "str.h" |
@@ -8,7 +9,7 @@ | |||
8 | 9 | ||
9 | static stralloc tmp; | 10 | static stralloc tmp; |
10 | 11 | ||
11 | void pathexec_run(const char *file,const char * const *argv,const char * const *envp) | 12 | void pathexec_run(const char *file, char *const *argv, char *const *envp) |
12 | { | 13 | { |
13 | const char *path; | 14 | const char *path; |
14 | unsigned int split; | 15 | unsigned int split; |
@@ -1,12 +1,15 @@ | |||
1 | /* Public domain. */ | 1 | /* Public domain. */ |
2 | 2 | ||
3 | #include <sys/types.h> | ||
4 | #include <unistd.h> | ||
5 | #include <grp.h> | ||
3 | #include "hasshsgr.h" | 6 | #include "hasshsgr.h" |
4 | #include "prot.h" | 7 | #include "prot.h" |
5 | 8 | ||
6 | int prot_gid(int gid) | 9 | int prot_gid(gid_t gid) |
7 | { | 10 | { |
8 | #ifdef HASSHORTSETGROUPS | 11 | #ifdef HASSHORTSETGROUPS |
9 | short x[2]; | 12 | gid_t x[2]; |
10 | x[0] = gid; x[1] = 73; /* catch errors */ | 13 | x[0] = gid; x[1] = 73; /* catch errors */ |
11 | if (setgroups(1,x) == -1) return -1; | 14 | if (setgroups(1,x) == -1) return -1; |
12 | #else | 15 | #else |
@@ -3,7 +3,7 @@ | |||
3 | #ifndef PROT_H | 3 | #ifndef PROT_H |
4 | #define PROT_H | 4 | #define PROT_H |
5 | 5 | ||
6 | extern int prot_gid(int); | 6 | extern int prot_gid(gid_t); |
7 | extern int prot_uid(int); | 7 | extern int prot_uid(int); |
8 | 8 | ||
9 | #endif | 9 | #endif |
@@ -27,7 +27,7 @@ Documentation in sgetopt.3. | |||
27 | int opterr = 1; | 27 | int opterr = 1; |
28 | const char *optprogname = 0; | 28 | const char *optprogname = 0; |
29 | 29 | ||
30 | int getopt(int argc,const char *const *argv,const char *opts) | 30 | int getopt(int argc,char *const *argv,const char *opts) |
31 | { | 31 | { |
32 | int c; | 32 | int c; |
33 | const char *s; | 33 | const char *s; |
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | #include "subgetopt.h" | 17 | #include "subgetopt.h" |
18 | 18 | ||
19 | extern int sgetoptmine(int,const char *const *,const char *); | 19 | extern int sgetoptmine(int,char *const *,const char *); |
20 | extern int sgetopterr; | 20 | extern int sgetopterr; |
21 | extern const char *sgetoptprogname; | 21 | extern const char *sgetoptprogname; |
22 | 22 | ||
diff --git a/subgetopt.c b/subgetopt.c index 85ace96..a23e0d7 100644 --- a/subgetopt.c +++ b/subgetopt.c | |||
@@ -16,7 +16,7 @@ const char *optarg = 0; | |||
16 | int optproblem = 0; | 16 | int optproblem = 0; |
17 | int optdone = SUBGETOPTDONE; | 17 | int optdone = SUBGETOPTDONE; |
18 | 18 | ||
19 | int sgopt(int argc,const char *const *argv,const char *opts) | 19 | int sgopt(int argc,char *const *argv,const char *opts) |
20 | { | 20 | { |
21 | int c; | 21 | int c; |
22 | const char *s; | 22 | const char *s; |
diff --git a/subgetopt.h b/subgetopt.h index 41ad26a..5163148 100644 --- a/subgetopt.h +++ b/subgetopt.h | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #define SUBGETOPTDONE -1 | 16 | #define SUBGETOPTDONE -1 |
17 | 17 | ||
18 | extern int subgetopt(int,const char *const *,const char *); | 18 | extern int subgetopt(int,char *const *,const char *); |
19 | extern const char *subgetoptarg; | 19 | extern const char *subgetoptarg; |
20 | extern int subgetoptind; | 20 | extern int subgetoptind; |
21 | extern int subgetoptpos; | 21 | extern int subgetoptpos; |