* [uml-devel] [PATCH] tunctl add group support
@ 2007-11-01 17:18 Alon Bar-Lev
0 siblings, 0 replies; only message in thread
From: Alon Bar-Lev @ 2007-11-01 17:18 UTC (permalink / raw)
To: user-mode-linux-devel
Add support for -g (group) parameter to set permission of group
based.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
---
diff -urNp tools-20060323.org/tunctl/tunctl.c tools-20060323/tunctl/tunctl.c
--- tools-20060323.org/tunctl/tunctl.c 2002-09-11 01:18:06.000000000 +0300
+++ tools-20060323/tunctl/tunctl.c 2007-11-01 17:05:09.000000000 +0200
@@ -9,13 +9,14 @@
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
+#include <grp.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <linux/if_tun.h>
static void Usage(char *name)
{
- fprintf(stderr, "Create: %s [-b] [-u owner] [-t device-name] "
+ fprintf(stderr, "Create: %s [-b] [ -g group ] [-u owner] [-t device-name] "
"[-f tun-clone-device]\n", name);
fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
name);
@@ -29,11 +30,13 @@ int main(int argc, char **argv)
{
struct ifreq ifr;
struct passwd *pw;
+ struct group *gr;
long owner = geteuid();
+ long group = getegid();
int tap_fd, opt, delete = 0, brief = 0;
char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end;
- while((opt = getopt(argc, argv, "bd:f:t:u:")) > 0){
+ while((opt = getopt(argc, argv, "bd:f:t:u:g:")) > 0){
switch(opt) {
case 'b':
brief = 1;
@@ -58,6 +61,19 @@ int main(int argc, char **argv)
Usage(name);
}
break;
+ case 'g':
+ gr = getgrnam(optarg);
+ if(gr != NULL){
+ group = gr->gr_gid;
+ break;
+ }
+ group = strtol(optarg, &end, 0);
+ if(*end != '\0'){
+ fprintf(stderr, "'%s' is neither a groupname nor a numeric gid.\n",
+ optarg);
+ Usage(name);
+ }
+ break;
case 't':
tun = optarg;
break;
@@ -104,10 +120,17 @@ int main(int argc, char **argv)
perror("TUNSETPERSIST");
exit(1);
}
+#ifndef TUNSETGROUP
+#define TUNSETGROUP _IOW('T', 206, int)
+#endif
+ if(ioctl(tap_fd, TUNSETGROUP, group) < 0){
+ perror("TUNSETGROUP");
+ group=-1;
+ }
if(brief)
printf("%s\n", ifr.ifr_name);
- else printf("Set '%s' persistent and owned by uid %ld\n", ifr.ifr_name,
- owner);
+ else printf("Set '%s' persistent and owned by gid %ld uid %ld\n",
+ ifr.ifr_name, group, owner);
}
return(0);
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-11-01 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-01 17:18 [uml-devel] [PATCH] tunctl add group support Alon Bar-Lev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.