summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chpst.c31
-rw-r--r--pathexec.h6
-rw-r--r--pathexec_env.c8
-rw-r--r--pathexec_run.c3
-rw-r--r--prot.c7
-rw-r--r--prot.h2
-rw-r--r--sgetopt.c2
-rw-r--r--sgetopt.h2
-rw-r--r--subgetopt.c2
-rw-r--r--subgetopt.h2
10 files changed, 35 insertions, 30 deletions
diff --git a/chpst.c b/chpst.c
index f1b8ed9..2b9eb01 100644
--- a/chpst.c
+++ b/chpst.c
@@ -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
41char *set_user =0; 42char *set_user =0;
42char *env_user =0; 43char *env_user =0;
43const char *argv0 =0; 44char *argv0 =0;
44const char *env_dir =0; 45const char *env_dir =0;
45unsigned int verbose =0; 46unsigned int verbose =0;
46unsigned int pgrp =0; 47unsigned int pgrp =0;
@@ -258,14 +259,14 @@ void slimit() {
258} 259}
259 260
260/* argv[0] */ 261/* argv[0] */
261void setuidgid(int, const char *const *); 262void setuidgid(int, char *const *);
262void envuidgid(int, const char *const *); 263void envuidgid(int, char *const *);
263void envdir(int, const char *const *); 264void envdir(int, char *const *);
264void pgrphack(int, const char *const *); 265void pgrphack(int, char *const *);
265void setlock(int, const char *const *); 266void setlock(int, char *const *);
266void softlimit(int, const char *const *); 267void softlimit(int, char *const *);
267 268
268int main(int argc, const char **argv) { 269int 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) {
366void setuidgid_usage() { 367void setuidgid_usage() {
367 strerr_die4x(100, "usage: ", progname, USAGE_SETUIDGID, "\n"); 368 strerr_die4x(100, "usage: ", progname, USAGE_SETUIDGID, "\n");
368} 369}
369void setuidgid(int argc, const char *const *argv) { 370void 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) {
379void envuidgid_usage() { 380void envuidgid_usage() {
380 strerr_die4x(100, "usage: ", progname, USAGE_ENVUIDGID, "\n"); 381 strerr_die4x(100, "usage: ", progname, USAGE_ENVUIDGID, "\n");
381} 382}
382void envuidgid(int argc, const char *const *argv) { 383void 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) {
392void envdir_usage() { 393void envdir_usage() {
393 strerr_die4x(100, "usage: ", progname, USAGE_ENVDIR, "\n"); 394 strerr_die4x(100, "usage: ", progname, USAGE_ENVDIR, "\n");
394} 395}
395void envdir(int argc, const char *const *argv) { 396void 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) {
405void pgrphack_usage() { 406void pgrphack_usage() {
406 strerr_die4x(100, "usage: ", progname, USAGE_PGRPHACK, "\n"); 407 strerr_die4x(100, "usage: ", progname, USAGE_PGRPHACK, "\n");
407} 408}
408void pgrphack(int argc, const char *const *argv) { 409void 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) {
415void setlock_usage() { 416void setlock_usage() {
416 strerr_die4x(100, "usage: ", progname, USAGE_SETLOCK, "\n"); 417 strerr_die4x(100, "usage: ", progname, USAGE_SETLOCK, "\n");
417} 418}
418void setlock(int argc, const char *const *argv) { 419void 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}
452void softlimit(int argc, const char *const *argv) { 453void 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)
diff --git a/pathexec.h b/pathexec.h
index d46ab17..8d850e7 100644
--- a/pathexec.h
+++ b/pathexec.h
@@ -3,9 +3,9 @@
3#ifndef PATHEXEC_H 3#ifndef PATHEXEC_H
4#define PATHEXEC_H 4#define PATHEXEC_H
5 5
6extern void pathexec_run(const char *,const char * const *,const char * const *); 6extern void pathexec_run(const char *, char *const *, char *const *);
7extern int pathexec_env(const char *,const char *); 7extern int pathexec_env(const char *,const char *);
8extern void pathexec_env_run(const char *, const char * const *); 8extern void pathexec_env_run(const char *, char *const *);
9extern void pathexec(const char * const *); 9extern 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
25void pathexec_env_run(const char *file, const char *const *argv) 25void 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
71void pathexec(const char *const *argv) 71void 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
9static stralloc tmp; 10static stralloc tmp;
10 11
11void pathexec_run(const char *file,const char * const *argv,const char * const *envp) 12void 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;
diff --git a/prot.c b/prot.c
index 79a88c5..1ffd20c 100644
--- a/prot.c
+++ b/prot.c
@@ -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
6int prot_gid(int gid) 9int 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
diff --git a/prot.h b/prot.h
index 2e5cb81..47a4204 100644
--- a/prot.h
+++ b/prot.h
@@ -3,7 +3,7 @@
3#ifndef PROT_H 3#ifndef PROT_H
4#define PROT_H 4#define PROT_H
5 5
6extern int prot_gid(int); 6extern int prot_gid(gid_t);
7extern int prot_uid(int); 7extern int prot_uid(int);
8 8
9#endif 9#endif
diff --git a/sgetopt.c b/sgetopt.c
index 8bb608f..778bca2 100644
--- a/sgetopt.c
+++ b/sgetopt.c
@@ -27,7 +27,7 @@ Documentation in sgetopt.3.
27int opterr = 1; 27int opterr = 1;
28const char *optprogname = 0; 28const char *optprogname = 0;
29 29
30int getopt(int argc,const char *const *argv,const char *opts) 30int 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;
diff --git a/sgetopt.h b/sgetopt.h
index bf8bce6..eb4cbf8 100644
--- a/sgetopt.h
+++ b/sgetopt.h
@@ -16,7 +16,7 @@
16 16
17#include "subgetopt.h" 17#include "subgetopt.h"
18 18
19extern int sgetoptmine(int,const char *const *,const char *); 19extern int sgetoptmine(int,char *const *,const char *);
20extern int sgetopterr; 20extern int sgetopterr;
21extern const char *sgetoptprogname; 21extern 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;
16int optproblem = 0; 16int optproblem = 0;
17int optdone = SUBGETOPTDONE; 17int optdone = SUBGETOPTDONE;
18 18
19int sgopt(int argc,const char *const *argv,const char *opts) 19int 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
18extern int subgetopt(int,const char *const *,const char *); 18extern int subgetopt(int,char *const *,const char *);
19extern const char *subgetoptarg; 19extern const char *subgetoptarg;
20extern int subgetoptind; 20extern int subgetoptind;
21extern int subgetoptpos; 21extern int subgetoptpos;