summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ip/ftpd.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2019-09-21 23:36:44 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2019-09-21 23:36:44 +0200
commit71a1d11a81faba020649408e8c9eaeb10095a341 (patch)
treea6bd0c245ad0beba3235ec268cf342da3182fb7e /sys/src/cmd/ip/ftpd.c
parent5993760e143bfab2a29fa3d5a4655ed5842fd21f (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/ip/ftpd.c')
-rw-r--r--sys/src/cmd/ip/ftpd.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/src/cmd/ip/ftpd.c b/sys/src/cmd/ip/ftpd.c
index 1aa395b89..df91065bb 100644
--- a/sys/src/cmd/ip/ftpd.c
+++ b/sys/src/cmd/ip/ftpd.c
@@ -606,6 +606,7 @@ passcmd(char *response)
{
char namefile[128];
AuthInfo *ai;
+ Dir nd;
if(response == nil)
response = "";
@@ -632,9 +633,17 @@ passcmd(char *response)
ch->nresp = strlen(response);
ai = auth_response(ch);
if(ai == nil || auth_chuid(ai, nil) < 0) {
+ auth_freeAI(ai);
slowdown();
return reply("530 Not logged in: %r");
}
+ /* chown network connection */
+ nulldir(&nd);
+ nd.mode = 0660;
+ nd.uid = ai->cuid;
+ dirfwstat(0, &nd);
+
+ auth_freeAI(ai);
auth_freechal(ch);
ch = nil;