diff --git a/cmdline.cc b/cmdline.cc index 51b439b..5f97cbc 100644 --- a/cmdline.cc +++ b/cmdline.cc @@ -342,11 +342,10 @@ uint64_t parseRLimit(int res, const char *optarg, unsigned long mul) { return cur.rlim_max; } if (!util::isANumber(optarg)) { - LOG_F("RLIMIT %d needs a numeric or 'max'/'hard'/'def'/'soft'/'inf' " - "value " - "('%s' " - "provided)", - res, optarg); + LOG_F( + "RLIMIT %s (%d) needs a numeric value or 'max'/'hard'/'def'/'soft'/'inf' value " + "(%s provided)", + util::rLimName(res).c_str(), res, QC(optarg)); } errno = 0; uint64_t val = strtoull(optarg, NULL, 0); diff --git a/subproc.cc b/subproc.cc index 3ef143f..95923c8 100644 --- a/subproc.cc +++ b/subproc.cc @@ -230,7 +230,7 @@ static void newProc(nsjconf_t* nsjconf, int netfd, int fd_in, int fd_out, int fd execv(nsjconf->exec_file.c_str(), (char* const*)argv.data()); } - PLOG_E("execve('%s') failed", nsjconf->exec_file.c_str()); + PLOG_E("execve(%s) failed", QC(nsjconf->exec_file)); } static void addProc(nsjconf_t* nsjconf, pid_t pid, int sock) { diff --git a/util.cc b/util.cc index 7f9d1fc..b882d69 100644 --- a/util.cc +++ b/util.cc @@ -313,6 +313,44 @@ const std::string sigName(int signo) { return res; } +const std::string rLimName(int res) { + std::string ret; + + struct { + const int res; + const char* const name; + } static const rLimNames[] = { + NS_VALSTR_STRUCT(RLIMIT_CPU), + NS_VALSTR_STRUCT(RLIMIT_FSIZE), + NS_VALSTR_STRUCT(RLIMIT_DATA), + NS_VALSTR_STRUCT(RLIMIT_STACK), + NS_VALSTR_STRUCT(RLIMIT_CORE), + NS_VALSTR_STRUCT(RLIMIT_RSS), + NS_VALSTR_STRUCT(RLIMIT_NOFILE), + NS_VALSTR_STRUCT(RLIMIT_AS), + NS_VALSTR_STRUCT(RLIMIT_NPROC), + NS_VALSTR_STRUCT(RLIMIT_MEMLOCK), + NS_VALSTR_STRUCT(RLIMIT_LOCKS), + NS_VALSTR_STRUCT(RLIMIT_SIGPENDING), + NS_VALSTR_STRUCT(RLIMIT_MSGQUEUE), + NS_VALSTR_STRUCT(RLIMIT_NICE), + NS_VALSTR_STRUCT(RLIMIT_RTPRIO), + NS_VALSTR_STRUCT(RLIMIT_RTTIME), + }; + + for (const auto& i : rLimNames) { + if (res == i.res) { + ret.append(i.name); + return ret; + } + } + + ret.append("RLIMITUNKNOWN("); + ret.append(std::to_string(res)); + ret.append(")"); + return ret; +} + const std::string timeToStr(time_t t) { char timestr[128]; struct tm utctime; diff --git a/util.h b/util.h index d2ebd16..b1de1d7 100644 --- a/util.h +++ b/util.h @@ -65,6 +65,7 @@ const std::string StrQuote(const std::string& str); bool isANumber(const char* s); uint64_t rnd64(void); const std::string sigName(int signo); +const std::string rLimName(int res); const std::string timeToStr(time_t t); std::vector strSplit(const std::string str, char delim); long syscall(long sysno, uintptr_t a0 = 0, uintptr_t a1 = 0, uintptr_t a2 = 0, uintptr_t a3 = 0,