Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getpeercred operation on unix request socket #117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bjne
Copy link

@bjne bjne commented Sep 5, 2018

SO_PEERCRED is afaik available on Linux only, and so far only on unix sockets.
This command will not be compiled on other platforms.

syntax:
local client = assert(ngx.req.socket(true))
uid, gid, pid = client:getpeercred()
if not uid then
...
end

SO_PEERCRED is afaik available on Linux only, so this command
will not be compiled on other platforms.

syntax:

uid, gid, pid = client:getpeercred()
if not uid then
    ...
end
@agentzh
Copy link
Member

agentzh commented Sep 5, 2018

@bjne Should we reuse the existing getoption() method instead? There are just too many getsockopt() possibilities.

Also, I think we should add a feature test for the SO_PEERCRED thing directly in the config file instead of assuming all linux versions do support this thing.

For such things without I/O, it might indeed be more flexible to expose the fd from the cosocket object.

@bjne
Copy link
Author

bjne commented Sep 5, 2018

@agentzh
getpeercred is inspired by luasocket's getpeername, but I have no strong opinions here, so just tell me what to do. sock:getoption("peercred")?

Agree with feature testing, will look into it.

so you are suggesting exposing sock:fd()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants