Skip to content

Commit 5db2b86

Browse files
committed
return strerror as second value, just like pledge
1 parent 7c8be37 commit 5db2b86

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

example/openbsd-example.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
o = require("openbsd")
22

33
-- Test out unveil
4-
ret = o.unveil(".", "rwx")
5-
print("unveil: " .. ret)
4+
ret, errstr = o.unveil(".", "rwx")
5+
print("unveil:", ret, errstr)
66

77
-- Same as pledge("rpath", NULL)
88
ret, s = o.pledge("rpath stdio")
9-
print(ret, s)
9+
print("pledge:", ret, s)
1010

1111
-- Same as pledge("rpath stdio wpath", "rpath stdio")
1212
ret, s = o.pledge("rpath stdio wpath", "rpath stdio")
13-
14-
print(ret, s)
13+
print("pledge:", ret, s)
1514

1615
print(o.arc4random())
1716

src/lua-openbsd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ int lua_unveil(lua_State *L)
9898
ret = unveil(path, mode);
9999
lua_pushnumber(L, ret);
100100

101+
if (ret == -1) {
102+
lua_pushstring(L, strerror(errno));
103+
return 2;
104+
}
105+
101106
return 1;
102107
}
103108

0 commit comments

Comments
 (0)