components/proftpd/mod_solaris_audit.c
changeset 1848 289daf750b26
parent 598 398722c80922
child 4634 a4940ac4947c
equal deleted inserted replaced
1847:b43426a2f6ba 1848:289daf750b26
     1 /*
     1 /*
     2  * ProFTPD - FTP server daemon
     2  * ProFTPD - FTP server daemon
     3  * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; either version 2 of the License, or
     7  * the Free Software Foundation; either version 2 of the License, or
     8  * (at your option) any later version.
     8  * (at your option) any later version.
   109 static void audit_failure(pool *p, char *authuser) {
   109 static void audit_failure(pool *p, char *authuser) {
   110   adt_event_data_t *event = NULL;
   110   adt_event_data_t *event = NULL;
   111   const char *how;
   111   const char *how;
   112   int saved_errno = 0;
   112   int saved_errno = 0;
   113   struct passwd pwd;
   113   struct passwd pwd;
       
   114   struct passwd *result = NULL;
   114   char *pwdbuf = NULL;
   115   char *pwdbuf = NULL;
   115   size_t pwdbuf_len;
   116   size_t pwdbuf_len;
   116   long pwdbuf_len_max;
   117   long pwdbuf_len_max;
   117   uid_t uid = ADT_NO_ATTRIB;
   118   uid_t uid = ADT_NO_ATTRIB;
   118   gid_t gid = ADT_NO_ATTRIB;
   119   gid_t gid = ADT_NO_ATTRIB;
   131     how = "couldn't start adt session";
   132     how = "couldn't start adt session";
   132     goto fail;
   133     goto fail;
   133   }
   134   }
   134 
   135 
   135   if ((authuser != NULL) && (authuser[0] != NULL) &&
   136   if ((authuser != NULL) && (authuser[0] != NULL) &&
   136     (getpwnam_r(authuser, &pwd, pwdbuf, pwdbuf_len) != NULL)) {
   137     (getpwnam_r(authuser, &pwd, pwdbuf, pwdbuf_len, &result) == 0) &&
       
   138     (result != NULL)) {
   137     uid = pwd.pw_uid;
   139     uid = pwd.pw_uid;
   138     gid = pwd.pw_gid;
   140     gid = pwd.pw_gid;
   139   } 
   141   } 
   140 
   142 
   141   if (adt_set_user(asession, uid, gid, uid, gid, NULL, ADT_NEW) != 0) {
   143   if (adt_set_user(asession, uid, gid, uid, gid, NULL, ADT_NEW) != 0) {