356 lua_pushboolean(L, 0); |
357 lua_pushboolean(L, 0); |
357 lua_pushstring(L, "invalid-gid"); |
358 lua_pushstring(L, "invalid-gid"); |
358 return 2; |
359 return 2; |
359 } |
360 } |
360 |
361 |
|
362 int lc_umask(lua_State* L) |
|
363 { |
|
364 char old_mode_string[7]; |
|
365 mode_t old_mode = umask(strtoul(luaL_checkstring(L, 1), NULL, 8)); |
|
366 |
|
367 snprintf(old_mode_string, sizeof(old_mode_string), "%03o", old_mode); |
|
368 old_mode_string[sizeof(old_mode_string)-1] = 0; |
|
369 lua_pushstring(L, old_mode_string); |
|
370 |
|
371 return 1; |
|
372 } |
|
373 |
361 /* Like POSIX's setrlimit()/getrlimit() API functions. |
374 /* Like POSIX's setrlimit()/getrlimit() API functions. |
362 * |
375 * |
363 * Syntax: |
376 * Syntax: |
364 * pposix.setrlimit( resource, soft limit, hard limit) |
377 * pposix.setrlimit( resource, soft limit, hard limit) |
365 * |
378 * |
504 lua_pushcfunction(L, lc_setuid); |
517 lua_pushcfunction(L, lc_setuid); |
505 lua_setfield(L, -2, "setuid"); |
518 lua_setfield(L, -2, "setuid"); |
506 lua_pushcfunction(L, lc_setgid); |
519 lua_pushcfunction(L, lc_setgid); |
507 lua_setfield(L, -2, "setgid"); |
520 lua_setfield(L, -2, "setgid"); |
508 |
521 |
|
522 lua_pushcfunction(L, lc_umask); |
|
523 lua_setfield(L, -2, "umask"); |
|
524 |
509 lua_pushcfunction(L, lc_setrlimit); |
525 lua_pushcfunction(L, lc_setrlimit); |
510 lua_setfield(L, -2, "setrlimit"); |
526 lua_setfield(L, -2, "setrlimit"); |
511 |
527 |
512 lua_pushcfunction(L, lc_getrlimit); |
528 lua_pushcfunction(L, lc_getrlimit); |
513 lua_setfield(L, -2, "getrlimit"); |
529 lua_setfield(L, -2, "getrlimit"); |