From: Benedikt Boehm Date: Fri, 27 Apr 2007 09:01:20 +0000 (+0000) Subject: add link command to chroot-sh X-Git-Tag: release-0.30.214~69 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83109802d0b4ab88856b6fe5ad270bac6967a531;p=util-vserver.git add link command to chroot-sh git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2536 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/src/chroot-sh.c b/src/chroot-sh.c index 0e1ffda..1dc696a 100644 --- a/src/chroot-sh.c +++ b/src/chroot-sh.c @@ -192,6 +192,24 @@ execChmod(int argc, char *argv[]) return res; } +static int +execLink(int argc, char *argv[]) +{ + int res = EXIT_SUCCESS; + + if (argc!=3) { + WRITE_MSG(2, "Need exactly two files for 'link' operation; try '--help' for more information\n"); + return wrapper_exit_code; + } + + if (symlink(argv[1], argv[2])==-1) { + PERROR_Q(ENSC_WRAPPERS_PREFIX "link", argv[1]); + res = EXIT_FAILURE; + } + + return res; +} + static struct Command { char const *cmd; int (*handler)(int argc, char *argv[]); @@ -203,6 +221,7 @@ static struct Command { { "rm", execRm }, { "mkdir", execMkdir }, { "chmod", execChmod }, + { "link", execLink }, { 0,0 } }; @@ -224,7 +243,8 @@ showHelp() " rm + ... unlink the given files\n" " mkdir + ... create the given directories\n" " chmod +\n" - " ... change access permissions of files\n\n" + " ... change access permissions of files\n" + " link dst> ... create a symbolic link from to \n\n" "Please report bugs to " PACKAGE_BUGREPORT "\n"); exit(0); }