mirror of https://git.qorg11.net/k9core.git
Added chown.c
Please someone use strtok() to get the group -R flag is needed as always
This commit is contained in:
parent
f4dc0887a9
commit
530bb5c584
|
@ -0,0 +1,28 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
|
/* TODO: use strtok() to get the group */
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if(argc == 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"No command given\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const char *user = argv[1];
|
||||||
|
|
||||||
|
struct passwd *data = getpwnam(user);
|
||||||
|
uid_t uid = data->pw_gid;
|
||||||
|
gid_t gid = data->pw_gid; /* Change this with the strtok() thing */
|
||||||
|
|
||||||
|
for(int i = 2; i<=argc; i++)
|
||||||
|
{
|
||||||
|
chown(argv[i],uid,gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue