commit | author | age
|
48e9c1
|
1 |
#include <stdio.h> |
T |
2 |
#include <string.h> |
|
3 |
#include <unistd.h> |
|
4 |
|
|
5 |
// set the UID this script will run as (root user) |
|
6 |
#define UID 0 |
|
7 |
#define CMD "/usr/sbin/dbmail-users" |
|
8 |
|
|
9 |
/* INSTALLING: |
|
10 |
gcc -o chgdbmailusers chgdbmailusers.c |
|
11 |
chown root.apache chgdbmailusers |
|
12 |
strip chgdbmailusers |
|
13 |
chmod 4550 chgdbmailusers |
|
14 |
*/ |
|
15 |
|
|
16 |
main(int argc, char *argv[]) |
|
17 |
{ |
|
18 |
int cnt,rc,cc; |
f6336f
|
19 |
char cmnd[1024]; |
48e9c1
|
20 |
|
T |
21 |
strcpy(cmnd, CMD); |
|
22 |
|
|
23 |
if (argc > 1) |
|
24 |
{ |
|
25 |
for (cnt = 1; cnt < argc; cnt++) |
|
26 |
{ |
|
27 |
strcat(cmnd, " "); |
|
28 |
strcat(cmnd, argv[cnt]); |
|
29 |
} |
|
30 |
} |
|
31 |
else |
|
32 |
{ |
|
33 |
fprintf(stderr, "__ %s: failed %d %d\n", argv[0], rc, cc); |
|
34 |
return 255; |
|
35 |
} |
|
36 |
|
|
37 |
cc = setuid(UID); |
|
38 |
rc = system(cmnd); |
|
39 |
|
3505d5
|
40 |
if ((rc != 0) || (cc != 0)) |
48e9c1
|
41 |
{ |
T |
42 |
fprintf(stderr, "__ %s: failed %d %d\n", argv[0], rc, cc); |
|
43 |
return 1; |
|
44 |
} |
|
45 |
|
|
46 |
return 0; |
|
47 |
} |