2
* Copyright Red Hat Inc. 2008
4
* Author: Steve Olivieri <sjo@redhat.com>
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of version 2.1 of the GNU Lesser General Public License
8
* as published by the Free Software Foundation.
10
* This program is distributed in the hope that it would be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
#include <sys/types.h>
26
* This is just a simple program for changing a UID or a GID. Comment out
27
* whichever block you don't want to use.
29
int main(int argc, char *argv[])
47
printf("Usage: %s <uid_value> \n", argv[0]);
51
pwd = getpwnam(argv[1]);
53
fprintf(stdout, "Setting UID to %s (%d).\n", pwd->pw_name, uid);
54
if ((ret = setuid(uid))) {
55
fprintf(stderr, "Call to setuid() failed with error: %s\n",
62
// grp = getgrnam("root");
64
// fprintf(stdout, "Setting GID to %s (%d).\n",
65
// grp->gr_name, gid);
66
// if ((ret = setgid(gid))) {
67
// fprintf(stderr, "Call to setgid() failed with error:"
68
// " %s\n", strerror(errno));