diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-09-21 23:36:44 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-09-21 23:36:44 +0200 |
commit | 71a1d11a81faba020649408e8c9eaeb10095a341 (patch) | |
tree | a6bd0c245ad0beba3235ec268cf342da3182fb7e /sys/src/cmd/upas/imap4d | |
parent | 5993760e143bfab2a29fa3d5a4655ed5842fd21f (diff) |
cmd/ip/*: chown the network connection after authentication
for servers that handle incoming network connections and authentication,
change the owner of the network connection file to the authenticated user
after successfull authentication.
note that we set the permissions as well to 0660 because old devip used
to unconditionally set the bits.
Diffstat (limited to 'sys/src/cmd/upas/imap4d')
-rw-r--r-- | sys/src/cmd/upas/imap4d/auth.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/src/cmd/upas/imap4d/auth.c b/sys/src/cmd/upas/imap4d/auth.c index 748174f52..27174ddfb 100644 --- a/sys/src/cmd/upas/imap4d/auth.c +++ b/sys/src/cmd/upas/imap4d/auth.c @@ -63,9 +63,15 @@ setupuser(AuthInfo *ai) if(ai){ strecpy(username, username + sizeof username, ai->cuid); - - if(auth_chuid(ai, nil) == -1) + if(auth_chuid(ai, nil) < 0) bye("user auth failed: %r"); + else { /* chown network connection */ + Dir nd; + nulldir(&nd); + nd.mode = 0660; + nd.uid = ai->cuid; + dirfwstat(Bfildes(&bin), &nd); + } auth_freeAI(ai); }else strecpy(username, username + sizeof username, getuser()); |