Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / samba / source / utils / smbrun.c
blobb7c678411c66a58209dab0cbcec780f390340c68
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 external program running routine
5 Copyright (C) Andrew Tridgell 1992-1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
25 /*******************************************************************
26 close the low 3 fd's and open dev/null in their place
27 ********************************************************************/
28 static void close_fds(void)
30 int fd;
31 int i;
32 close(0); close(1); close(2);
33 /* try and use up these file descriptors, so silly
34 library routines writing to stdout etc won't cause havoc */
35 for (i=0;i<3;i++) {
36 fd = open("/dev/null",O_RDWR,0);
37 if (fd < 0) fd = open("/dev/null",O_WRONLY,0);
38 if (fd != i) return;
44 This is a wrapper around the system() call to allow commands to run correctly
45 as non root from a program which is switching between root and non-root
47 It takes 3 arguments as uid,gid,command and runs command after
48 becoming a non-root user */
49 int main(int argc,char *argv[])
51 uid_t uid;
52 gid_t gid;
54 close_fds();
56 if (argc != 4) exit(2);
58 uid = (uid_t)atoi(argv[1]);
59 gid = (gid_t)atoi(argv[2]);
61 become_user_permanently( uid, gid);
63 /* paranoia :-) */
64 if (getuid() != uid)
65 return(3);
67 if (geteuid() != getuid())
68 return(4);
70 /* this is to make sure that the system() call doesn't run forever */
71 alarm(30);
73 return(system(argv[3]));