removed wrappers-*
[util-vserver.git] / util-vserver / src / testsuite / rpm-fake-test.c
1 // $Id$    --*- c -*--
2
3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19 #ifdef HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include "src/wrappers.h"
24
25 #include <grp.h>
26 #include <pwd.h>
27 #include <unistd.h>
28 #include <stdbool.h>
29 #include <stdlib.h>
30 #include <stdio.h>
31
32 int wrapper_exit_code = 1;
33
34 int main(int argc, char *argv[])
35 {
36   char          buf[1000];
37
38   while (true) {
39     char        *ptr = buf;
40     char        c;
41     do {
42       if (read(0, &c, 1)==0) break;
43       if (c=='\n') break;
44       *ptr++ = c;
45     } while (ptr<buf+sizeof(buf));
46     *ptr = '\0';
47     if (ptr==buf) break;
48
49     switch (buf[0]) {
50       case 'P'          : {
51         struct passwd   *pw;
52         
53         pw = getpwnam(buf+1);
54         printf("P(%s) = ", buf+1);
55         if (pw) printf("%u\n", pw->pw_uid);
56         else    printf("(null)\n");
57         
58         break;
59       }
60
61       case 'G'          : {
62         struct group    *gr;
63         
64         gr = getgrnam(buf+1);
65         printf("G(%s) = ", buf+1);
66         if (gr) printf("%u\n", gr->gr_gid);
67         else    printf("(null)\n");
68         
69         break;
70       }
71
72       case 'C'          :
73         switch (buf[1]) {
74           case 'g'      :  endgrent(); break;
75           case 'p'      :  endpwent(); break;
76           default       :  abort(); break;
77         }
78         break;
79
80       default           :
81         abort();
82     }
83   }
84
85   {
86     char const *        cmd[] = { "/bin/grep", "^s_context", "/proc/self/status", 0 };
87     Eexecv(cmd[0], cmd);
88   }
89 }