Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Vlad Glagolev (4b6e4e871529a59224c97a83e42f1ea08af95856)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Vlad Glagolev <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Vlad Glagolev (4b6e4e871529a59224c97a83e42f1ea08af95856)
  • Date: Thu, 2 Oct 2014 13:47:11 -0500

GIT changes to master grimoire by Vlad Glagolev <stealth AT sourcemage.org>:

ChangeLog | 3
utils/ulimits/DETAILS | 15 ++++
utils/ulimits/HISTORY | 2
utils/ulimits/PRE_BUILD | 4 +
utils/ulimits/ulimits.patch | 155
++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 179 insertions(+)

New commits:
commit 4b6e4e871529a59224c97a83e42f1ea08af95856
Author: Vlad Glagolev <stealth AT sourcemage.org>
Commit: Vlad Glagolev <stealth AT sourcemage.org>

ulimits: new spell, user limits utility

diff --git a/ChangeLog b/ChangeLog
index fb622c1..27ca08a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2014-10-02 Vlad Glagolev <stealth AT sourcemage.org>
+ * utils/ulimits: new spell, user limits utility
+
2014-09-29 Vlad Glagolev <stealth AT sourcemage.org>
* net/megatools: new spell, command line client for mega.co.nz
* http/phantomjs: new spell, headless WebKit scriptable with a
diff --git a/utils/ulimits/DETAILS b/utils/ulimits/DETAILS
new file mode 100755
index 0000000..4446c90
--- /dev/null
+++ b/utils/ulimits/DETAILS
@@ -0,0 +1,15 @@
+ SPELL=ulimits
+ VERSION=0.3.0
+ BRANCH=`echo $VERSION|cut -d . -f 1,2`
+ SOURCE=$SPELL-$VERSION.tar.gz
+ SOURCE_URL[0]=http://www.incenp.org/files/softs/$SPELL/$BRANCH/$SOURCE
+
SOURCE_HASH=sha512:1e355f3701e6ebb983a3b6ee391c0218946e3b9036e13cd1f93a10d4d4a0e6bb81a76cb576f3eeb842eabf21ffe998db661b45168710cb6d4882e4679567194c
+SOURCE_DIRECTORY="$BUILD_DIRECTORY/$SPELL-$VERSION"
+ WEB_SITE=http://www.incenp.org/dvlpt/ulimits.html
+ LICENSE[0]=GPL
+ ENTERED=20141002
+ SHORT="user limits utility"
+cat << EOF
+Ulimits is a tool to enforce the resource limits set forth by the
administrator
+of a GNU/Linux system.
+EOF
diff --git a/utils/ulimits/HISTORY b/utils/ulimits/HISTORY
new file mode 100644
index 0000000..1144f35
--- /dev/null
+++ b/utils/ulimits/HISTORY
@@ -0,0 +1,2 @@
+2014-10-02 Vlad Glagolev <stealth AT sourcemage.org>
+ * DETAILS, PRE_BUILD, ulimits.patch: spell created, version 0.3.0
diff --git a/utils/ulimits/PRE_BUILD b/utils/ulimits/PRE_BUILD
new file mode 100755
index 0000000..896ac92
--- /dev/null
+++ b/utils/ulimits/PRE_BUILD
@@ -0,0 +1,4 @@
+default_pre_build &&
+cd "$SOURCE_DIRECTORY" &&
+
+patch -p0 < "$SPELL_DIRECTORY/ulimits.patch"
diff --git a/utils/ulimits/ulimits.patch b/utils/ulimits/ulimits.patch
new file mode 100644
index 0000000..0abf00c
--- /dev/null
+++ b/utils/ulimits/ulimits.patch
@@ -0,0 +1,155 @@
+# Author: Vlad Glagolev <stealth AT sourcemage.org>
+#
+# Changes in this patch:
+# * groups and comments support
+# * bugfix for not found user or empty file
+
+--- src/ulimits.c.orig 2013-01-28 14:39:13.000000000 +0400
++++ src/ulimits.c 2014-10-02 21:39:49.318495483 +0400
+@@ -29,6 +29,7 @@
+
+ #include <unistd.h>
+ #include <pwd.h>
++#include <grp.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/resource.h>
+@@ -95,6 +96,47 @@
+ #define PLIMIT_PRIORITY RLIMIT_NLIMITS + 3
+
+ /**
++ * Check if user is in the group
++ *
++ * @param uname A pointer to a username
++ * @param gname A pointer to a groupname
++ * @return 0 if a user belongs to group, -1 otherwise
++ */
++static int user_in_group(const *uname, const char *gname)
++{
++ struct group *groupdata;
++ char *const *list;
++
++ if (uname == NULL || gname == NULL) {
++ return -1;
++ }
++
++ if (*gname == '@') {
++ gname++;
++ } else {
++ return -1;
++ }
++
++ groupdata = getgrnam(gname);
++
++ if (groupdata == NULL) {
++ return -1;
++ }
++
++ list = groupdata->gr_mem;
++
++ while (*list != NULL) {
++ if (strcmp(*list, uname) == 0) {
++ return 0;
++ }
++
++ list++;
++ }
++
++ return -1;
++}
++
++/**
+ * Parses a single limit specification.
+ * This function parses a single limit specification (that is, a single
+ * letter followed by a numerical value) and fills the provided
+@@ -109,7 +151,7 @@
+ parse_limit_value(char **s, struct rlimit_setting *rlimit)
+ {
+ char *c, *p;
+- int value;
++ int value, inf;
+
+ if ( s == NULL || *s == NULL || rlimit == NULL ) {
+ errno = EINVAL;
+@@ -123,7 +165,16 @@
+
+ /* Get the numerical value for the limit. */
+ errno = 0;
+- value = strtol(c + 1, &p, 10);
++
++ /* A single dash means no limits. */
++ if (*(c+1) == '-') {
++ p = c+2;
++ inf = 1;
++ } else {
++ value = strtol(c + 1, &p, 10);
++ inf = 0;
++ }
++
+ if ( errno || p == c + 1 )
+ return -1;
+
+@@ -132,7 +183,7 @@
+ #define ULIMIT(symbol, letter, unused1, factor, unused2) \
+ case letter: \
+ rlimit->resource = symbol; \
+- rlimit->limit = value * factor; \
++ rlimit->limit = inf == 1 ? RLIM_INFINITY : value * factor; \
+ break;
+ #include "ulimits.h"
+ #undef ULIMIT
+@@ -174,15 +225,6 @@
+ while ( *s == ' ' || *s == '\t' )
+ s += 1;
+
+- /* A single dash means no limits. */
+- if ( *s == '-' && *(s + 1) == '\0' ) {
+- for ( ; n < RLIMIT_NLIMITS && n < len - 1 ; n++ ) {
+- rlimits[n].resource = n;
+- rlimits[n].limit = RLIM_INFINITY;
+- }
+- s += 1;
+- }
+-
+ while ( *s != '\0' && n < len - 1 ) {
+ if ( parse_limit_value(&s, &(rlimits[n])) < 0 )
+ return -1;
+@@ -280,9 +322,11 @@
+ while ( ! found && ! feof(f) ) {
+ c = fgetc(f);
+
+- if ( isgraph(c) && n < len - 1 )
++ if (c == '#')
++ discard_line(f);
++ else if ( isgraph(c) && n < len - 1 )
+ buffer[n++] = (char)c;
+- else if ( c == ' ' && n > 0 )
++ else if ( (c == ' ' || c == '\t') && n > 0 )
+ found = 1;
+ else {
+ n = 0;
+@@ -357,18 +401,21 @@
+
+ if ( strcmp(nbuf, "*") == 0 )
+ default_found = get_line(f, lbuf, sizeof(lbuf)) != -1;
+- else if ( strcmp(nbuf, user) == 0 )
++ else if ( strcmp(nbuf, user) == 0 || user_in_group(user, nbuf) == 0
)
+ user_found = get_line(f, lbuf, sizeof(lbuf)) != -1;
+ else
+ discard_line(f);
+ }
+ fclose(f);
+
+- if ( user_found || default_found )
++ if ( user_found || default_found ) {
+ if ( (n = parse_limit_string(lbuf, rlimits, len)) == -1 )
+ errno = EBADMSG;
+
+- return n;
++ return n;
++ }
++
++ return -1;
+ }
+
+ static int



  • [SM-Commit] GIT changes to master grimoire by Vlad Glagolev (4b6e4e871529a59224c97a83e42f1ea08af95856), Vlad Glagolev, 10/02/2014

Archive powered by MHonArc 2.6.24.

Top of Page