1 | /* |
---|
2 | * signup-scripts-frontend |
---|
3 | * Copyright (C) 2006 Jeff Arnold <jbarnold@mit.edu> |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or |
---|
6 | * modify it under the terms of the GNU General Public License |
---|
7 | * as published by the Free Software Foundation; either version 2 |
---|
8 | * of the License, or (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public License |
---|
16 | * along with this program; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
---|
18 | * |
---|
19 | * See /COPYRIGHT in this repository for more information. |
---|
20 | */ |
---|
21 | |
---|
22 | #include <stdlib.h> |
---|
23 | #include <stdio.h> |
---|
24 | |
---|
25 | extern char **environ; |
---|
26 | |
---|
27 | int main(int argc, char **argv) { |
---|
28 | environ=NULL; |
---|
29 | if(argc != 2) { |
---|
30 | exit(1); |
---|
31 | } |
---|
32 | |
---|
33 | char uid[21]; // 64-bit uid requires 21 |
---|
34 | int retval = snprintf(uid, 21, "%d", getuid()); |
---|
35 | if(retval < 0 || retval >= 21) { |
---|
36 | exit(1); |
---|
37 | } |
---|
38 | if(setreuid(geteuid(), -1) != 0) { |
---|
39 | exit(1); |
---|
40 | } |
---|
41 | char *v[3]; |
---|
42 | #define BACKEND_PATH "/usr/local/sbin/signup-scripts-backend" |
---|
43 | v[0] = BACKEND_PATH; |
---|
44 | v[1] = argv[1]; |
---|
45 | v[2] = NULL; |
---|
46 | execv(BACKEND_PATH, v); |
---|
47 | return 1; |
---|
48 | } |
---|