summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-10-09 20:47:59 +0000
committergreen <green@FreeBSD.org>1999-10-09 20:47:59 +0000
commit14b89019c6f151d71fd698017bd5f36e1843357d (patch)
tree787eed7bab22ec8900a8687e7efee05a03b5f3e0
parentf980526bf65a754175b095da7e9c65301bc51ef6 (diff)
downloadFreeBSD-src-14b89019c6f151d71fd698017bd5f36e1843357d.zip
FreeBSD-src-14b89019c6f151d71fd698017bd5f36e1843357d.tar.gz
This implements the RLIMIT_SBSIZE ("sbsize") administrative limits for
userland. Currently, it can be enforced by login and csh. More shells supporting sbsize are welcome.
-rw-r--r--bin/csh/func.c1
-rw-r--r--lib/libutil/login_class.31
-rw-r--r--lib/libutil/login_class.c1
-rw-r--r--usr.bin/limits/limits.14
-rw-r--r--usr.bin/limits/limits.c35
5 files changed, 29 insertions, 13 deletions
diff --git a/bin/csh/func.c b/bin/csh/func.c
index 070fc84..2a1b802 100644
--- a/bin/csh/func.c
+++ b/bin/csh/func.c
@@ -1142,6 +1142,7 @@ static struct limits {
{ RLIMIT_MEMLOCK, "memorylocked", 1024, "kbytes" },
{ RLIMIT_NPROC, "maxproc", 1, "" },
{ RLIMIT_NOFILE, "openfiles", 1, "" },
+ { RLIMIT_SBSIZE, "sbsize ", 1, "bytes" },
{ -1, NULL, 0, NULL }
};
diff --git a/lib/libutil/login_class.3 b/lib/libutil/login_class.3
index 4bb0185..edbaa89 100644
--- a/lib/libutil/login_class.3
+++ b/lib/libutil/login_class.3
@@ -109,6 +109,7 @@ memoryuse RLIMIT_RSS
memorylocked RLIMIT_MEMLOCK
maxproc RLIMIT_NPROC
openfiles RLIMIT_NOFILE
+sbsize RLIMIT_SBSIZE
.Ed
.It LOGIN_SETPRIORITY
Set the scheduling priority for the current process based on the
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c
index 589ea4f..2cd65bd 100644
--- a/lib/libutil/login_class.c
+++ b/lib/libutil/login_class.c
@@ -59,6 +59,7 @@ static struct login_res {
{ "maxproc", login_getcapnum, RLIMIT_NPROC },
{ "openfiles", login_getcapnum, RLIMIT_NOFILE },
{ "coredumpsize", login_getcapsize, RLIMIT_CORE },
+ { "sbsize", login_getcapnum, RLIMIT_SBSIZE },
{ NULL, 0, 0 }
};
diff --git a/usr.bin/limits/limits.1 b/usr.bin/limits/limits.1
index 258dc55..e0f0492 100644
--- a/usr.bin/limits/limits.1
+++ b/usr.bin/limits/limits.1
@@ -172,6 +172,10 @@ The exact syntax used for output depends upon the type of shell from
which
.Nm limits
is invoked.
+.It Fl b Op Ar limit
+Selects or sets the
+.Em sbsize
+resource limit.
.It Fl c Op Ar limit
Selects or sets (if 'limit' is specified) the
.Em coredumpsize
diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c
index b9de9a4..8061302 100644
--- a/usr.bin/limits/limits.c
+++ b/usr.bin/limits/limits.c
@@ -82,7 +82,8 @@ static struct {
{ " memoryuse%-4s %8s", " kb\n", 1024 },
{ " memorylocked%-4s %8s", " kb\n", 1024 },
{ " maxprocesses%-4s %8s", "\n", 1 },
- { " openfiles%-4s %8s", "\n", 1 }
+ { " openfiles%-4s %8s", "\n", 1 },
+ { " sbsize%-4s %8s", " bytes\n", 1 }
}
},
{ "sh", "unlimited", "", " -H", " -S", "",
@@ -95,7 +96,8 @@ static struct {
{ "ulimit%s -m %s", ";\n", 1024 },
{ "ulimit%s -l %s", ";\n", 1024 },
{ "ulimit%s -u %s", ";\n", 1 },
- { "ulimit%s -n %s", ";\n", 1 }
+ { "ulimit%s -n %s", ";\n", 1 },
+ { "ulimit%s -b %s", ";\n", 1 }
}
},
{ "csh", "unlimited", "", " -h", "", NULL,
@@ -108,7 +110,8 @@ static struct {
{ "limit%s memoryuse %s", ";\n", 1024 },
{ "limit%s memorylocked %s", ";\n", 1024 },
{ "limit%s maxproc %s", ";\n", 1 },
- { "limit%s openfiles %s", ";\n", 1 }
+ { "limit%s openfiles %s", ";\n", 1 },
+ { "limit%s sbsize %s", ";\n", 1 }
}
},
{ "bash|bash2", "unlimited", "", " -H", " -S", "",
@@ -121,7 +124,8 @@ static struct {
{ "ulimit%s -m %s", ";\n", 1024 },
{ "ulimit%s -l %s", ";\n", 1024 },
{ "ulimit%s -u %s", ";\n", 1 },
- { "ulimit%s -n %s", ";\n", 1 }
+ { "ulimit%s -n %s", ";\n", 1 },
+ { "ulimit%s -b %s", ";\n", 1 }
}
},
{ "tcsh", "unlimited", "", " -h", "", NULL,
@@ -134,7 +138,8 @@ static struct {
{ "limit%s memoryuse %s", ";\n", 1024 },
{ "limit%s memorylocked %s", ";\n", 1024 },
{ "limit%s maxproc %s", ";\n", 1 },
- { "limit%s descriptors %s", ";\n", 1 }
+ { "limit%s descriptors %s", ";\n", 1 },
+ { "limit%s sbsize %s", ";\n", 1 }
}
},
{ "ksh|pdksh", "unlimited", "", " -H", " -S", "",
@@ -147,7 +152,8 @@ static struct {
{ "ulimit%s -m %s", ";\n", 1024 },
{ "ulimit%s -l %s", ";\n", 1024 },
{ "ulimit%s -p %s", ";\n", 1 },
- { "ulimit%s -n %s", ";\n", 1 }
+ { "ulimit%s -n %s", ";\n", 1 },
+ { "ulimit%s -b %s", ";\n", 1 }
}
},
{ "zsh", "unlimited", "", " -H", " -S", "",
@@ -160,7 +166,8 @@ static struct {
{ "ulimit%s -m %s", ";\n", 1024 },
{ "ulimit%s -l %s", ";\n", 1024 },
{ "ulimit%s -u %s", ";\n", 1 },
- { "ulimit%s -n %s", ";\n", 1 }
+ { "ulimit%s -n %s", ";\n", 1 },
+ { "ulimit%s -b %s", ";\n", 1 }
}
},
{ "rc|es", "unlimited", "", " -h", "", NULL,
@@ -173,7 +180,8 @@ static struct {
{ "limit%s memoryuse %s", ";\n", 1024 },
{ "limit%s lockedmemory %s", ";\n", 1024 },
{ "limit%s processes %s", ";\n", 1 },
- { "limit%s descriptors %s", ";\n", 1 }
+ { "limit%s descriptors %s", ";\n", 1 },
+ { "limit%s sbsize %s", ";\n", 1 }
}
},
{ NULL }
@@ -190,8 +198,9 @@ static struct {
{ "coredumpsize", login_getcapsize },
{ "memoryuse", login_getcapsize },
{ "memorylocked", login_getcapsize },
- { "maxproc", login_getcapnum, },
- { "openfiles", login_getcapnum }
+ { "maxproc", login_getcapnum },
+ { "openfiles", login_getcapnum },
+ { "sbsize", login_getcapnum }
};
/*
@@ -202,7 +211,7 @@ static struct {
* to be modified accordingly!
*/
-#define RCS_STRING "tfdscmlun"
+#define RCS_STRING "tfdscmlunb"
static rlim_t resource_num(int which, int ch, const char *str);
static void usage(const char *msg, ...);
@@ -238,7 +247,7 @@ main(int argc, char *argv[])
}
optarg = NULL;
- while ((ch = getopt(argc, argv, ":EeC:U:BSHac:d:f:l:m:n:s:t:u:")) != -1) {
+ while ((ch = getopt(argc, argv, ":EeC:U:BSHabc:d:f:l:m:n:s:t:u:")) != -1) {
switch(ch) {
case 'a':
doall = 1;
@@ -450,7 +459,7 @@ usage(char const *msg, ...)
va_end(argp);
}
(void)fprintf(stderr,
-"usage: limits [-C class|-U user] [-eaSHBE] [-cdflmnstu [val]] [[name=val ...] cmd]\n");
+"usage: limits [-C class|-U user] [-eaSHBE] [-bcdflmnstu [val]] [[name=val ...] cmd]\n");
exit(EXIT_FAILURE);
}
OpenPOWER on IntegriCloud