X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fchroot-sh.c;h=123ba874077e1590dadf7ee3e424d13e83a45bc7;hb=148ab3024621f97b9cf95091657db2448098bc66;hp=0e1ffdae58d4aafa9ad2b3773ef876b29363079e;hpb=50e3c58ac5d9afe773c732578b4af0dff8ce588f;p=util-vserver.git diff --git a/src/chroot-sh.c b/src/chroot-sh.c index 0e1ffda..123ba87 100644 --- a/src/chroot-sh.c +++ b/src/chroot-sh.c @@ -192,6 +192,42 @@ 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 int +execMv(int argc, char *argv[]) +{ + int res = EXIT_SUCCESS; + + if (argc!=3) { + WRITE_MSG(2, "Need exactly two files for 'mv' operation; try '--help' for more information\n"); + return wrapper_exit_code; + } + + if (rename(argv[1], argv[2])==-1) { + PERROR_Q(ENSC_WRAPPERS_PREFIX "mv", argv[1]); + res = EXIT_FAILURE; + } + + return res; +} + static struct Command { char const *cmd; int (*handler)(int argc, char *argv[]); @@ -203,6 +239,8 @@ static struct Command { { "rm", execRm }, { "mkdir", execMkdir }, { "chmod", execChmod }, + { "link", execLink }, + { "mv", execMv }, { 0,0 } }; @@ -217,15 +255,17 @@ showHelp() "directory, and symlinks can point to files under the current path only.\n" "\n" "The supported commands are:\n" - " cat ... gives out to stdout\n" - " append ... appends stdin to which is created when needed\n" - " truncate ... clear and fill it with stdin; the is\n" + " cat ... gives out to stdout\n" + " append ... appends stdin to which is created when needed\n" + " truncate ... clear and fill it with stdin; the is\n" " created when needed\n" - " rm + ... unlink the given files\n" - " mkdir + ... create the given directories\n" + " rm + ... unlink the given files\n" + " mkdir + ... create the given directories\n" " chmod +\n" - " ... change access permissions of files\n\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n"); + " ... change access permissions of files\n" + " link ... create a symbolic link from to \n" + " mv ... rename to \n" + "\nPlease report bugs to " PACKAGE_BUGREPORT "\n"); exit(0); }