Created
December 8, 2020 14:27
-
-
Save dndx/b8b87f5abaac11ad89c89d8fd505a68f to your computer and use it in GitHub Desktop.
LuaJIT checking user and group exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require("ffi") | |
local C = ffi.C | |
ffi.cdef([[ | |
struct group *getgrnam(const char *name); | |
struct passwd *getpwnam(const char *name); | |
]]) | |
if C.getpwnam("kong") == nil then | |
print("kong user does not exist") | |
else | |
print("kong user exists") | |
end | |
if C.getpwnam("root") == nil then | |
print("root user does not exist") | |
else | |
print("root user exists") | |
end | |
if C.getgrnam("kong") == nil then | |
print("kong group does not exist") | |
else | |
print("kong group exists") | |
end | |
if C.getgrnam("root") == nil then | |
print("root group does not exist") | |
else | |
print("root group exists") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment