X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fexec-ulimit.c;h=c599220a54bf77bf9472ba2c915bcf4c21e42cdc;hb=4fbda6a580ea77c11a507c1c45f1bceed3653722;hp=84219438d03e8c2d320c8674d398d8157c882a07;hpb=80c6a600b76bf075102c12bc4c4245e31b1694da;p=util-vserver.git diff --git a/util-vserver/src/exec-ulimit.c b/util-vserver/src/exec-ulimit.c index 8421943..c599220 100644 --- a/util-vserver/src/exec-ulimit.c +++ b/util-vserver/src/exec-ulimit.c @@ -58,6 +58,16 @@ readValue(int fd, char const *filename) if (strncmp(buf, "inf", 3)==0) return RLIM_INFINITY; res = strtol(buf, &errptr, 0); + if (errptr!=buf) { + switch (*errptr) { + case 'M' : res *= 1024; /* fallthrough */ + case 'K' : res *= 1024; ++errptr; break; + case 'm' : res *= 1000; /* fallthrough */ + case 'k' : res *= 1000; ++errptr; break; + default : break; + } + } + if (errptr==buf || (*errptr!='\0' && *errptr!='\n')) { WRITE_MSG(2, "Invalid limit in '"); WRITE_STR(2, filename); @@ -115,13 +125,40 @@ readSingleLimit(struct rlimit *lim, char const *fname_base) return is_modified; } +static void +showHelp(int fd, char const *cmd, int res) +{ + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_STR(fd, + " *\n\n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); +} + +static void +showVersion() +{ + WRITE_MSG(1, + "exec-ulimit " VERSION " -- executes programs with resource limits\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2003 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); +} + int main(int argc, char *argv[]) { size_t i; int cur_fd = Eopen(".", O_RDONLY, 0); - + + if (argc==2) { + if (strcmp(argv[1], "--help")==0) showHelp(1,argv[0],0); + if (strcmp(argv[1], "--version")==0) showVersion(); + } + if (argc<3) { - WRITE_MSG(2, "Usage: exec-ulimit *\n"); + WRITE_MSG(2, "Bad parameter count; use '--help' for more information.\n"); exit(255); }