aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2020-09-07 17:59:18 +0200
committerqorg11 <qorg@vxempire.xyz>2020-09-07 17:59:18 +0200
commitb244eb30373f3a5e82c511404f4b6725b604cad7 (patch)
treee6645a6e03db7ed6cabc11c97723f306466e528d
parentea00641408b50b763f1d0a2d0d42ef225b554636 (diff)
downloadk9core-b244eb30373f3a5e82c511404f4b6725b604cad7.tar.gz
k9core-b244eb30373f3a5e82c511404f4b6725b604cad7.zip
added chgrp
-rw-r--r--src/chgrp.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/chgrp.c b/src/chgrp.c
new file mode 100644
index 0000000..75873a6
--- /dev/null
+++ b/src/chgrp.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <grp.h>
+#include <errno.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+ if(argc == 1 || argc == 2)
+ {
+ fprintf(stderr,"usage: chgrp group file...\n");
+ return 1;
+ }
+ struct group *group_data = getgrnam(argv[1]);
+ gid_t gid = group_data->gr_gid;
+ for(int i = 2; i<argc; i++)
+ {
+ if(chown(argv[i],gid,getuid()) == -1)
+ fprintf(stderr,"error %i = %s\n",errno,strerror(errno));
+
+ }
+
+}