author | Thanukrishnamurthy Madhusudhanan<thanukrishnamurthy.madhusudha@oracle.com> |
Wed, 15 Jul 2015 10:23:59 -0700 | |
changeset 4653 | 4fb953160e20 |
parent 4634 | a4940ac4947c |
permissions | -rw-r--r-- |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
2 |
* ProFTPD - FTP server daemon |
4634
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
3 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
4 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
7 |
* the Free Software Foundation; either version 2 of the License, or |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
9 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
14 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
18 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
19 |
* As a special exemption, copyright holders give permission to link |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
20 |
* this program with OpenSSL, and distribute the resulting executable, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
21 |
* without including the source code for OpenSSL in the source distribution. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
22 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
23 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
24 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
25 |
#include "conf.h" |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
26 |
#include <bsm/adt.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
27 |
#include <bsm/adt_event.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
28 |
#include <security/pam_appl.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
29 |
#include <sys/types.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
30 |
#include <pwd.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
31 |
#include <unistd.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
32 |
#include <ucred.h> |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
33 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
34 |
#ifndef ADT_ftpd |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
35 |
#define ADT_ftpd 152 |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
36 |
#endif |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
37 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
38 |
#ifndef ADT_ftpd_logout |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
39 |
#define ADT_ftpd_logout 153 |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
40 |
#endif |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
41 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
42 |
module solaris_audit_module; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
43 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
44 |
static adt_session_data_t *asession = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
45 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
46 |
static int auth_retval = PAM_AUTH_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
47 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
48 |
static void audit_autherr_ev(const void *event_data, void *user_data) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
49 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
50 |
switch (*(int *)event_data) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
51 |
case PR_AUTH_NOPWD: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
52 |
auth_retval = PAM_USER_UNKNOWN; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
53 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
54 |
case PR_AUTH_AGEPWD: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
55 |
auth_retval = PAM_CRED_EXPIRED; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
56 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
57 |
case PR_AUTH_DISABLEDPWD: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
58 |
auth_retval = PAM_ACCT_EXPIRED; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
59 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
60 |
case PR_AUTH_CRED_INSUFF: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
61 |
auth_retval = PAM_CRED_INSUFFICIENT; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
62 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
63 |
case PR_AUTH_CRED_UNAVAIL: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
64 |
auth_retval = PAM_CRED_UNAVAIL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
65 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
66 |
case PR_AUTH_CRED_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
67 |
auth_retval = PAM_CRED_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
68 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
69 |
case PR_AUTH_UNAVAIL: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
70 |
auth_retval = PAM_AUTHINFO_UNAVAIL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
71 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
72 |
case PR_AUTH_MAXTRIES: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
73 |
auth_retval = PAM_MAXTRIES; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
74 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
75 |
case PR_AUTH_INIT_FAIL: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
76 |
auth_retval = PAM_SESSION_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
77 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
78 |
case PR_AUTH_NEWTOK: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
79 |
auth_retval = PAM_NEW_AUTHTOK_REQD; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
80 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
81 |
case PR_AUTH_OPEN_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
82 |
auth_retval = PAM_OPEN_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
83 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
84 |
case PR_AUTH_SYMBOL_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
85 |
auth_retval = PAM_SYMBOL_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
86 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
87 |
case PR_AUTH_SERVICE_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
88 |
auth_retval = PAM_SERVICE_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
89 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
90 |
case PR_AUTH_SYSTEM_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
91 |
auth_retval = PAM_SYSTEM_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
92 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
93 |
case PR_AUTH_BUF_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
94 |
auth_retval = PAM_BUF_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
95 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
96 |
case PR_AUTH_CONV_ERR: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
97 |
auth_retval = PAM_CONV_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
98 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
99 |
case PR_AUTH_PERM_DENIED: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
100 |
auth_retval = PAM_PERM_DENIED; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
101 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
102 |
default: /* PR_AUTH_BADPWD */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
103 |
auth_retval = PAM_AUTH_ERR; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
104 |
break; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
105 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
106 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
107 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
108 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
109 |
static void audit_failure(pool *p, char *authuser) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
110 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
111 |
const char *how; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
112 |
int saved_errno = 0; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
113 |
struct passwd pwd; |
1848
289daf750b26
18552341 proftpd doesn't build on 45
Tomas Klacko <tomas.klacko@oracle.com>
parents:
598
diff
changeset
|
114 |
struct passwd *result = NULL; |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
115 |
char *pwdbuf = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
116 |
size_t pwdbuf_len; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
117 |
long pwdbuf_len_max; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
118 |
uid_t uid = ADT_NO_ATTRIB; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
119 |
gid_t gid = ADT_NO_ATTRIB; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
120 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
121 |
if ((pwdbuf_len_max = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
122 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
123 |
how = "couldn't determine maximum size of password buffer"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
124 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
125 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
126 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
127 |
pwdbuf_len = (size_t)pwdbuf_len_max; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
128 |
pwdbuf = pcalloc(p, pwdbuf_len); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
129 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
130 |
if (adt_start_session(&asession, NULL, ADT_USE_PROC_DATA) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
131 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
132 |
how = "couldn't start adt session"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
133 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
134 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
135 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
136 |
if ((authuser != NULL) && (authuser[0] != NULL) && |
1848
289daf750b26
18552341 proftpd doesn't build on 45
Tomas Klacko <tomas.klacko@oracle.com>
parents:
598
diff
changeset
|
137 |
(getpwnam_r(authuser, &pwd, pwdbuf, pwdbuf_len, &result) == 0) && |
289daf750b26
18552341 proftpd doesn't build on 45
Tomas Klacko <tomas.klacko@oracle.com>
parents:
598
diff
changeset
|
138 |
(result != NULL)) { |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
139 |
uid = pwd.pw_uid; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
140 |
gid = pwd.pw_gid; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
141 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
142 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
143 |
if (adt_set_user(asession, uid, gid, uid, gid, NULL, ADT_NEW) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
144 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
145 |
how = "couldn't set adt user"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
146 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
147 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
148 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
149 |
if ((event = adt_alloc_event(asession, ADT_ftpd)) == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
150 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
151 |
how = "couldn't allocate adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
152 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
153 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
154 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
155 |
if (adt_put_event(event, ADT_FAILURE, ADT_FAIL_PAM + auth_retval) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
156 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
157 |
how = "couldn't put adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
158 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
159 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
160 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
161 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
162 |
(void) adt_end_session(asession); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
163 |
asession = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
164 |
return; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
165 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
166 |
fail: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
167 |
pr_log_pri(PR_LOG_ERR, "Auditing of login failed: %s (%s)", how, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
168 |
strerror(saved_errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
169 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
170 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
171 |
(void) adt_end_session(asession); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
172 |
asession = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
173 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
174 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
175 |
static void audit_success(void) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
176 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
177 |
const char *how; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
178 |
int saved_errno = 0; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
179 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
180 |
if (adt_start_session(&asession, NULL, ADT_USE_PROC_DATA) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
181 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
182 |
how = "couldn't start adt session"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
183 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
184 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
185 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
186 |
if ((event = adt_alloc_event(asession, ADT_ftpd)) == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
187 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
188 |
how = "couldn't allocate adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
189 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
190 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
191 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
192 |
if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
193 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
194 |
how = "couldn't put adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
195 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
196 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
197 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
198 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
199 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
200 |
/* Don't end adt session - leave for when logging out. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
201 |
return; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
202 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
203 |
fail: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
204 |
pr_log_pri(PR_LOG_ERR, "Auditing of login failed: %s (%s)", how, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
205 |
strerror(saved_errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
206 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
207 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
208 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
209 |
/* Don't end adt session - leave for when logging out. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
210 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
211 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
212 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
213 |
static void audit_logout(void) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
214 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
215 |
const char *how; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
216 |
int saved_errno = 0; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
217 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
218 |
/* If audit session was not created during login then leave */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
219 |
if (asession == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
220 |
return; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
221 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
222 |
if ((event = adt_alloc_event(asession, ADT_ftpd_logout)) == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
223 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
224 |
how = "couldn't allocate adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
225 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
226 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
227 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
228 |
if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
229 |
saved_errno = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
230 |
how = "couldn't put adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
231 |
goto fail; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
232 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
233 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
234 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
235 |
(void) adt_end_session(asession); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
236 |
asession = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
237 |
return; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
238 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
239 |
fail: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
240 |
pr_log_pri(PR_LOG_ERR, "Auditing of logout failed: %s (%s)", how, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
241 |
strerror(saved_errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
242 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
243 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
244 |
(void) adt_end_session(asession); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
245 |
asession = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
246 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
247 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
248 |
/* Logout */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
249 |
static void audit_exit_ev(const void *event_data, void *user_data) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
250 |
audit_logout(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
251 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
252 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
253 |
/* Login passed */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
254 |
MODRET solaris_audit_post_pass(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
255 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
256 |
audit_success(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
257 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
258 |
/* Set handler for logout/timeout */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
259 |
pr_event_register(&solaris_audit_module, "core.exit", audit_exit_ev, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
260 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
261 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
262 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
263 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
264 |
/* Login failed */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
265 |
MODRET solaris_audit_post_fail(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
266 |
char *login_user; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
267 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
268 |
login_user = pr_table_get(session.notes, "mod_auth.orig-user", NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
269 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
270 |
audit_failure(cmd->tmp_pool, login_user); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
271 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
272 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
273 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
274 |
static int audit_sess_init(void) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
275 |
adt_session_data_t *aht; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
276 |
adt_termid_t *termid; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
277 |
priv_set_t *privset; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
278 |
int rval = -1; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
279 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
280 |
/* add privs for audit init */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
281 |
if ((privset = priv_allocset()) == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
282 |
pr_log_pri(PR_LOG_ERR, "Auditing privilege initialization failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
283 |
return rval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
284 |
} |
4634
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
285 |
|
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
286 |
(void) getppriv(PRIV_INHERITABLE, privset); |
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
287 |
priv_addset(privset, PRIV_PROC_AUDIT); |
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
288 |
(void) setppriv(PRIV_SET, PRIV_INHERITABLE, privset); |
a4940ac4947c
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login
William.D.Johnston <William.D.Johnston@oracle.com>
parents:
1848
diff
changeset
|
289 |
|
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
290 |
(void) getppriv(PRIV_EFFECTIVE, privset); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
291 |
priv_addset(privset, PRIV_SYS_AUDIT); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
292 |
(void) setppriv(PRIV_SET, PRIV_EFFECTIVE, privset); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
293 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
294 |
/* basic terminal id setup */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
295 |
if (adt_start_session(&aht, NULL, 0) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
296 |
pr_log_pri(PR_LOG_ERR, "pam adt_start_session: %s", strerror(errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
297 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
298 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
299 |
if (adt_load_termid(session.c->rfd, &termid) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
300 |
pr_log_pri(PR_LOG_ERR, "adt_load_termid: %s", strerror(errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
301 |
(void) adt_end_session(aht); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
302 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
303 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
304 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
305 |
if (adt_set_user(aht, ADT_NO_AUDIT, ADT_NO_AUDIT, 0, ADT_NO_AUDIT, termid, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
306 |
ADT_SETTID) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
307 |
pr_log_pri(PR_LOG_ERR, "adt_set_user: %", strerror(errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
308 |
free(termid); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
309 |
(void) adt_end_session(aht); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
310 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
311 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
312 |
free(termid); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
313 |
if (adt_set_proc(aht) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
314 |
pr_log_pri(PR_LOG_ERR, "adt_set_proc: %", strerror(errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
315 |
(void) adt_end_session(aht); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
316 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
317 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
318 |
(void) adt_end_session(aht); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
319 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
320 |
/* Set handler for authentication error */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
321 |
pr_event_register(&solaris_audit_module, "mod_auth.authentication-code", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
322 |
audit_autherr_ev, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
323 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
324 |
rval = 0; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
325 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
326 |
out: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
327 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
328 |
/* remove unneeded privileges */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
329 |
priv_delset(privset, PRIV_SYS_AUDIT); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
330 |
(void) setppriv(PRIV_SET, PRIV_EFFECTIVE, privset); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
331 |
(void) setpflags(PRIV_AWARE_RESET, 1); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
332 |
priv_freeset(privset); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
333 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
334 |
return rval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
335 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
336 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
337 |
#define EVENT_KEY "event" |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
338 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
339 |
/* Helper functions and global variables |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
340 |
* for the file transfer command handlers. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
341 |
* { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
342 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
343 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
344 |
static char src_realpath[PATH_MAX]; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
345 |
static char dst_realpath[PATH_MAX]; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
346 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
347 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
348 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
349 |
* If an error occurs in any of the file transfer handlers, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
350 |
* and the handler wants to return PR_ERROR(cmd), then it is necessary |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
351 |
* to send some FTP error message to user. This is in order to prevent |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
352 |
* a hang-up of the user's ftp client. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
353 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
354 |
* This function sends the 451 error message to the user. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
355 |
* It is only called in the "pre-" handlers. When a "pre-" handler |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
356 |
* returns PR_ERROR(cmd), then the corresponding "post_err-" |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
357 |
* handler is also called. Therefore it can happen that an error condition |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
358 |
* (such as no memory) can be logged (with the pr_log_pri() routine) twice. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
359 |
* Once in the "pre-" handler, and once in the "post_err-" handler. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
360 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
361 |
static void error_451(void) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
362 |
{ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
363 |
pr_response_add_err(R_451, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
364 |
"Requested action aborted: local error in processing.\n"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
365 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
366 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
367 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
368 |
* Allocate resources to process a command outcome. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
369 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
370 |
* All file transfer command handlers need to allocate adt_event_data_t |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
371 |
* structure and also make a copy of the command argument. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
372 |
* This function does both. If it can't, it logs an error and returns NULL. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
373 |
* On success, it returns the pointer (event) to the allocated adt_event_data_t |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
374 |
* structure. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
375 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
376 |
* If arg2 is not NULL, it makes a copy of the first (and only) command |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
377 |
* argument (using the memory pool "pool" from "cmd") and stores it to *arg2. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
378 |
* There must be always exactly one command argument, otherwise it is an error. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
379 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
380 |
* On success, the pointer to the created event structure is stored |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
381 |
* into cmd under "notes" variable, so that it is accessible |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
382 |
* by the subsequent corresponding "post-" or "post_err-" command handler. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
383 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
384 |
adt_event_data_t* __solaris_audit_pre_arg2( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
385 |
cmd_rec *cmd, const char* description, int event_type, char **arg2) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
386 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
387 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
388 |
const char *how = ""; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
389 |
char *tmp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
390 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
391 |
/* The ftp server code will save errno into this variable |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
392 |
* in case an error happens, and there is a valid errno for it. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
393 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
394 |
cmd->error_code = ADT_FAILURE; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
395 |
|
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
396 |
if (cmd->arg == NULL) { |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
397 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s failed: %s", |
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
398 |
description, "bad argument"); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
399 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
400 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
401 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
402 |
if (arg2 != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
403 |
*arg2 = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
404 |
|
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
405 |
if ((tmp = pstrdup(cmd->pool, cmd->arg)) == NULL) { |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
406 |
how = "no memory"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
407 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
408 |
description, cmd->arg, how); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
409 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
410 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
411 |
*arg2 = tmp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
412 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
413 |
|
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
414 |
if (cmd->notes == NULL) { |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
415 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
416 |
description, cmd->arg, "API error, notes is NULL"); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
417 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
418 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
419 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
420 |
if ((event = adt_alloc_event(asession, event_type)) == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
421 |
how = "couldn't allocate adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
422 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s(%s)", |
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
423 |
description, cmd->arg, how, strerror(errno)); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
424 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
425 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
426 |
|
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
427 |
if (pr_table_add(cmd->notes, EVENT_KEY, event, sizeof(*event)) == -1) { |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
428 |
how = "pr_table_add() failed"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
429 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
430 |
description, cmd->arg, how); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
431 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
432 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
433 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
434 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
435 |
return event; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
436 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
437 |
err: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
438 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
439 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
440 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
441 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
442 |
* This function implements logic that is common to most "post-" |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
443 |
* and "post_err-" file transfer command handlers. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
444 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
445 |
* It retrieves the pointer (event) to the adt_event_data_t structure |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
446 |
* from "cmd->notes" and logs it. This structure has been created by the |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
447 |
* __solaris_audit_pre_arg2() function. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
448 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
449 |
* Some audit event structures contain an optional *_stat member. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
450 |
* If "fill_attr" is not NULL, it is called to fill in this member, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
451 |
* before the audit event is logged. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
452 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
453 |
* This function always returns PR_DECLINED, even if it failed |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
454 |
* to log the audit event. The reason is that it is called in the |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
455 |
* "post-" file transfer command handlers, which means that the command |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
456 |
* has been already successfully executed by the ftp server. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
457 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
458 |
MODRET __solaris_audit_post(cmd_rec *cmd, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
459 |
const char* description, int exit_status, int __unused, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
460 |
const char* (*fill_event)(cmd_rec *cmd, adt_event_data_t *event)) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
461 |
{ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
462 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
463 |
const char* how = ""; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
464 |
const char* msg = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
465 |
size_t size = 0; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
466 |
int exit_error = cmd->error_code; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
467 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
468 |
event = (adt_event_data_t*)pr_table_remove(cmd->notes, EVENT_KEY, &size); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
469 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
470 |
how = "event is NULL"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
471 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s failed: %s", description, how); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
472 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
473 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
474 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
475 |
if (size != sizeof(*event)) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
476 |
how = "bad event size"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
477 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s failed: %s", description, how); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
478 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
479 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
480 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
481 |
if (fill_event != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
482 |
msg = fill_event(cmd, event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
483 |
if (msg != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
484 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s failed: %s", description, msg); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
485 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
486 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
487 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
488 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
489 |
/* It can happen, that the ftp command succeeds but only to some degree. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
490 |
* In such case, the exit_error might contain the errno number |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
491 |
* of the failure. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
492 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
493 |
if (exit_status == ADT_SUCCESS) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
494 |
if (exit_error == ADT_FAILURE) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
495 |
exit_error = ADT_SUCCESS; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
496 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
497 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
498 |
if (adt_put_event(event, exit_status, exit_error) != 0) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
499 |
how = "couldn't put adt event"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
500 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s failed: %s (%s)", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
501 |
description, how, strerror(errno)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
502 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
503 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
504 |
adt_free_event(event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
505 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
506 |
out: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
507 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
508 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
509 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
510 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
511 |
* This is a generic function to fill in the given "stat" member |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
512 |
* of some audit event structure. The path and the member are specified |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
513 |
* by the caller. The pointer to cmd is supplied, because the stat64 |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
514 |
* structure has to be allocated (the "stat" member is a pointer). |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
515 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
516 |
* The function returns NULL on success. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
517 |
* In case of an error, it returns a descriptive message. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
518 |
* This message is used by the caller to log an error. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
519 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
520 |
* For some file transfer commands, the "stat" member is filled in |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
521 |
* the "pre-" handler (because the file is expected to exist prior |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
522 |
* to the execution of the command). For other file transfer commands, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
523 |
* the "stat" member is filled in the "post-" handler (because |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
524 |
* the file is expected _not_ to exist prior to the execution of the command, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
525 |
* but to exist after the command execution). |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
526 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
527 |
static const char* __fill_attr |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
528 |
( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
529 |
cmd_rec *cmd, const char* path, adt_stat_t **ret) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
530 |
{ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
531 |
struct stat64 *ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
532 |
int err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
533 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
534 |
if (ret == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
535 |
return "NULL pointer"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
536 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
537 |
*ret = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
538 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
539 |
ptr = palloc(cmd->pool, sizeof(*ptr)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
540 |
if (ptr == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
541 |
return "no memory"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
542 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
543 |
err = stat64(path, ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
544 |
if (err == -1) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
545 |
return "stat64() failed"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
546 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
547 |
*ret = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
548 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
549 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
550 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
551 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
552 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
553 |
/* Delete file. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
554 |
static const char* dele_fill_attr(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
555 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
556 |
cmd, event->adt_ft_remove.f_path, &(event->adt_ft_remove.f_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
557 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
558 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
559 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
560 |
MODRET solaris_audit_pre_dele(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
561 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
562 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
563 |
char* rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
564 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
565 |
event = __solaris_audit_pre_arg2(cmd, "remove", ADT_ft_remove, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
566 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
567 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
568 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
569 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
570 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
571 |
rp = realpath(ptr, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
572 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
573 |
if (errno != ENOENT) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
574 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
575 |
"remove", ptr, "realpath() failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
576 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
577 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
578 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
579 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
580 |
/* If rp is NULL and errno is ENOENT, it means that |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
581 |
* the file to be deleted does not exist. In this case, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
582 |
* the post_dele_err callback will be called to log this. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
583 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
584 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
585 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
586 |
if (rp != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
587 |
ptr = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
588 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
589 |
event->adt_ft_remove.f_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
590 |
(void) dele_fill_attr(cmd, event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
591 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
592 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
593 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
594 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
595 |
MODRET solaris_audit_post_dele(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
596 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
597 |
cmd, "remove", ADT_SUCCESS, ADT_SUCCESS, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
598 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
599 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
600 |
MODRET solaris_audit_post_dele_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
601 |
return __solaris_audit_post(cmd, "remove", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
602 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
603 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
604 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
605 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
606 |
/* Make directory. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
607 |
MODRET solaris_audit_pre_mkd(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
608 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
609 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
610 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
611 |
event = __solaris_audit_pre_arg2(cmd, "mkdir", ADT_ft_mkdir, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
612 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
613 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
614 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
615 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
616 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
617 |
event->adt_ft_mkdir.d_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
618 |
event->adt_ft_mkdir.d_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
619 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
620 |
/* Value 0777 is hardcoded in the ftp server. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
621 |
event->adt_ft_mkdir.arg = 0777; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
622 |
event->adt_ft_mkdir.arg_id = 2; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
623 |
event->adt_ft_mkdir.arg_desc = "mode"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
624 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
625 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
626 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
627 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
628 |
static const char* mkd_fill_event(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
629 |
char *rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
630 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
631 |
rp = realpath(event->adt_ft_mkdir.d_path, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
632 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
633 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
634 |
return "realpath() failed"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
635 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
636 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
637 |
event->adt_ft_mkdir.d_path = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
638 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
639 |
cmd, event->adt_ft_mkdir.d_path, &(event->adt_ft_mkdir.d_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
640 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
641 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
642 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
643 |
static const char* mkd_fill_event_err(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
644 |
char *rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
645 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
646 |
rp = realpath(event->adt_ft_mkdir.d_path, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
647 |
if (rp != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
648 |
event->adt_ft_mkdir.d_path = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
649 |
(void) __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
650 |
cmd, event->adt_ft_mkdir.d_path, &(event->adt_ft_mkdir.d_attr)); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
651 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
652 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
653 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
654 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
655 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
656 |
MODRET solaris_audit_post_mkd(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
657 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
658 |
cmd, "mkdir", ADT_SUCCESS, ADT_SUCCESS, mkd_fill_event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
659 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
660 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
661 |
MODRET solaris_audit_post_mkd_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
662 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
663 |
cmd, "mkdir", ADT_FAILURE, ADT_FAILURE, mkd_fill_event_err); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
664 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
665 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
666 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
667 |
/* Remove directory. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
668 |
static const char* rmd_fill_attr(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
669 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
670 |
cmd, event->adt_ft_rmdir.f_path, &(event->adt_ft_rmdir.f_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
671 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
672 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
673 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
674 |
MODRET solaris_audit_pre_rmd(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
675 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
676 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
677 |
char* rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
678 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
679 |
event = __solaris_audit_pre_arg2(cmd, "rmdir", ADT_ft_rmdir, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
680 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
681 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
682 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
683 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
684 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
685 |
rp = realpath(ptr, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
686 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
687 |
if (errno != ENOENT) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
688 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
689 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
690 |
"rmdir", ptr, "realpath() failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
691 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
692 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
693 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
694 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
695 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
696 |
if (rp != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
697 |
ptr = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
698 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
699 |
event->adt_ft_rmdir.f_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
700 |
(void) rmd_fill_attr(cmd, event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
701 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
702 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
703 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
704 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
705 |
MODRET solaris_audit_post_rmd(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
706 |
return __solaris_audit_post(cmd, "rmdir", ADT_SUCCESS, ADT_SUCCESS, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
707 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
708 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
709 |
MODRET solaris_audit_post_rmd_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
710 |
return __solaris_audit_post(cmd, "rmdir", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
711 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
712 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
713 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
714 |
/* Get modification time and date. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
715 |
MODRET solaris_audit_pre_mdtm(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
716 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
717 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
718 |
char* rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
719 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
720 |
event = __solaris_audit_pre_arg2(cmd, "utimes", ADT_ft_utimes, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
721 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
722 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
723 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
724 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
725 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
726 |
rp = realpath(ptr, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
727 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
728 |
if (errno != ENOENT) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
729 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
730 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
731 |
"utimes", ptr, "realpath() failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
732 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
733 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
734 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
735 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
736 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
737 |
if (rp != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
738 |
ptr = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
739 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
740 |
event->adt_ft_utimes.f_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
741 |
event->adt_ft_utimes.f_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
742 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
743 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
744 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
745 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
746 |
static const char* mdtm_fill_attr(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
747 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
748 |
cmd, event->adt_ft_utimes.f_path, &(event->adt_ft_utimes.f_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
749 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
750 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
751 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
752 |
MODRET solaris_audit_post_mdtm(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
753 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
754 |
cmd, "utimes", ADT_SUCCESS, ADT_SUCCESS, mdtm_fill_attr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
755 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
756 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
757 |
MODRET solaris_audit_post_mdtm_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
758 |
return __solaris_audit_post(cmd, "utimes", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
759 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
760 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
761 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
762 |
/* Upload file. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
763 |
MODRET solaris_audit_pre_put(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
764 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
765 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
766 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
767 |
event = __solaris_audit_pre_arg2(cmd, "put", ADT_ft_put, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
768 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
769 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
770 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
771 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
772 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
773 |
event->adt_ft_put.f_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
774 |
event->adt_ft_put.f_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
775 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
776 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
777 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
778 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
779 |
static const char* put_fill_event(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
780 |
char *rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
781 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
782 |
rp = realpath(event->adt_ft_put.f_path, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
783 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
784 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
785 |
return "realpath() failed"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
786 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
787 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
788 |
event->adt_ft_put.f_path = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
789 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
790 |
cmd, event->adt_ft_put.f_path, &(event->adt_ft_put.f_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
791 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
792 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
793 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
794 |
MODRET solaris_audit_post_put(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
795 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
796 |
cmd, "put", ADT_SUCCESS, ADT_SUCCESS, put_fill_event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
797 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
798 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
799 |
MODRET solaris_audit_post_put_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
800 |
return __solaris_audit_post(cmd, "put", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
801 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
802 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
803 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
804 |
/* Download file. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
805 |
MODRET solaris_audit_pre_get(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
806 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
807 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
808 |
char* rp = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
809 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
810 |
event = __solaris_audit_pre_arg2(cmd, "get", ADT_ft_get, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
811 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
812 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
813 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
814 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
815 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
816 |
rp = realpath(ptr, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
817 |
if (rp == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
818 |
if (errno != ENOENT) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
819 |
cmd->error_code = errno; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
820 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
821 |
"get", ptr, "realpath() failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
822 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
823 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
824 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
825 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
826 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
827 |
if (rp != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
828 |
ptr = rp; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
829 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
830 |
event->adt_ft_get.f_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
831 |
event->adt_ft_get.f_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
832 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
833 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
834 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
835 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
836 |
static const char* get_fill_attr(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
837 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
838 |
cmd, event->adt_ft_get.f_path, &(event->adt_ft_get.f_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
839 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
840 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
841 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
842 |
MODRET solaris_audit_post_get(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
843 |
return __solaris_audit_post( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
844 |
cmd, "get", ADT_SUCCESS, ADT_SUCCESS, get_fill_attr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
845 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
846 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
847 |
MODRET solaris_audit_post_get_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
848 |
return __solaris_audit_post(cmd, "get", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
849 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
850 |
/* } */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
851 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
852 |
/* Rename file. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
853 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
854 |
* The rename file implementation uses malloc()/free(), |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
855 |
* which the ProFTP module interface prohibits. I do not see another way. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
856 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
857 |
* Any memory allocation method provided by the ProFTP API uses a memory pool. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
858 |
* To avoid malloc()/free() a persistent memory pool is needed. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
859 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
860 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
861 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
862 |
* To successfully log the rename audit event, a cooperation |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
863 |
* of RNFR and RNTO command handlers is necessary. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
864 |
* The RNFR command specifies the source file name, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
865 |
* and the RNTO command specifies the destination file name. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
866 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
867 |
* The RNFR command handlers save the source file in the "src_path" |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
868 |
* variable, so that it is available to the RNTO command handler, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
869 |
* which logs the audit event. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
870 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
871 |
static char* src_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
872 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
873 |
/* RNFR. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
874 |
static void __solaris_audit_rnfr_err(cmd_rec *cmd) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
875 |
{ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
876 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
877 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
878 |
if (src_path == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
879 |
return; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
880 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
881 |
event = __solaris_audit_pre_arg2(cmd, "RNFR", ADT_ft_rename, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
882 |
if (event == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
883 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
884 |
goto out; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
885 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
886 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
887 |
event->adt_ft_rename.src_path = src_path; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
888 |
event->adt_ft_rename.src_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
889 |
event->adt_ft_rename.dst_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
890 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
891 |
(void) __solaris_audit_post(cmd, "RNFR", ADT_FAILURE, ADT_FAILURE, NULL); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
892 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
893 |
out: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
894 |
free(src_path); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
895 |
src_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
896 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
897 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
898 |
MODRET solaris_audit_pre_rnfr(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
899 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
900 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
901 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
902 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
903 |
* If src_path is not NULL, it means that this RNFR command immediatelly |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
904 |
* follows a successfull RNFR command not terminated with a RNTO command. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
905 |
* In such case, log an audit error for this unterminated RNFR command, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
906 |
* and then continue normally. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
907 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
908 |
* A correctly working ftp client can not cause this situation to happen. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
909 |
* But this situation can be created, for instance, by manually sending |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
910 |
* commands to the ftp server with a telnet client. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
911 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
912 |
if (src_path != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
913 |
__solaris_audit_rnfr_err(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
914 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
915 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
916 |
* Prepare the audit event structure and remember the new src_path. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
917 |
* This audit event structure will be used, if the RNFR command fails. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
918 |
* It will be unused, if it succeeds. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
919 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
920 |
event = __solaris_audit_pre_arg2(cmd, "get", ADT_ft_rename, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
921 |
if (event == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
922 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
923 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
924 |
event->adt_ft_rename.src_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
925 |
event->adt_ft_rename.src_attr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
926 |
event->adt_ft_rename.dst_path = ""; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
927 |
|
598
398722c80922
7112588 proftpd in solaris 11 release does not handle spaces in filenames
tomas klacko - Sun Microsystems - Prague Czech Republic <tomas.klacko@oracle.com>
parents:
305
diff
changeset
|
928 |
src_path = strdup(cmd->arg); |
305
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
929 |
if (src_path == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
930 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
931 |
"RNFR", ptr, "no memory"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
932 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
933 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
934 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
935 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
936 |
err: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
937 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
938 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
939 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
940 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
941 |
* On success, the RNFR command handlers do not log any audit event. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
942 |
* A success means that a rename command is in progress and that |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
943 |
* the immediatelly following command is to be RNTO. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
944 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
945 |
MODRET solaris_audit_post_rnfr(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
946 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
947 |
char *ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
948 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
949 |
ptr = realpath(src_path, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
950 |
if (ptr == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
951 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
952 |
"RNFR", src_path, "realpath() failed"); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
953 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
954 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
955 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
956 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
957 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
958 |
* The argument to RNFR command is saved in src_path. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
959 |
* It will be used in the subsequent RNTO command, or RNFR command. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
960 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
961 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
962 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
963 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
964 |
/* It can happen, that RNFR command fails, but the source path exists. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
965 |
* Therefore make an attempt to resolve its realpath before doing |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
966 |
* the audit log. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
967 |
* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
968 |
* Even if the realpath() call fails, the src_path contents are still |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
969 |
* copied to src_realpath buffer. This makes them available to the RNTO |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
970 |
* command handlers. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
971 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
972 |
static const char* rnfr_err_fill_event(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
973 |
char *ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
974 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
975 |
if (src_path != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
976 |
ptr = realpath(src_path, src_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
977 |
if (ptr != NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
978 |
event->adt_ft_rename.src_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
979 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
980 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
981 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
982 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
983 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
984 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
985 |
* On error, an audit event is logged, specifying that a rename |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
986 |
* command failed. The destination path in the audit event structure |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
987 |
* is empty, simply because the corresponding RNTO command did not yet |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
988 |
* happen, and it is not suppossed to happen. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
989 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
990 |
MODRET solaris_audit_post_rnfr_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
991 |
MODRET ret; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
992 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
993 |
ret = __solaris_audit_post(cmd, "RNFR", ADT_FAILURE, ADT_FAILURE, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
994 |
rnfr_err_fill_event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
995 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
996 |
free(src_path); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
997 |
src_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
998 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
999 |
return ret; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1000 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1001 |
/* } RNFR. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1002 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1003 |
/* RNTO. { */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1004 |
static const char* rnto_fill_attr(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1005 |
return __fill_attr( |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1006 |
cmd, event->adt_ft_rename.src_path, &(event->adt_ft_rename.src_attr) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1007 |
); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1008 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1009 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1010 |
MODRET solaris_audit_pre_rnto(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1011 |
adt_event_data_t *event = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1012 |
const char* msg = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1013 |
char* ptr = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1014 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1015 |
event = __solaris_audit_pre_arg2(cmd, "get", ADT_ft_rename, &ptr); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1016 |
if (event == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1017 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1018 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1019 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1020 |
* If src_path is NULL, this means that there is no previous |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1021 |
* successfull RNFR command. The ftp server should know about this |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1022 |
* and terminate this RNTO command with an error (call the error callback). |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1023 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1024 |
event->adt_ft_rename.src_path = (src_path)?src_path:""; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1025 |
event->adt_ft_rename.dst_path = ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1026 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1027 |
/* |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1028 |
* If the code executes here, it means that there is a successfully finished |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1029 |
* RNFR command immediatelly before us, which means that the src_path exists, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1030 |
* and it should be therefore possible to get its status. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1031 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1032 |
msg = rnto_fill_attr(cmd, event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1033 |
if (msg != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1034 |
pr_log_pri(PR_LOG_ERR, "Auditing of %s(%s,%s) failed: %s", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1035 |
"RNTO", event->adt_ft_rename.src_path, ptr, msg); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1036 |
goto err; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1037 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1038 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1039 |
return PR_DECLINED(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1040 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1041 |
err: |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1042 |
error_451(); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1043 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1044 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1045 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1046 |
static const char* rnto_fill_event(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1047 |
char *ptr; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1048 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1049 |
ptr = realpath(event->adt_ft_rename.dst_path, dst_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1050 |
if (ptr == NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1051 |
return "realpath() failed"; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1052 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1053 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1054 |
event->adt_ft_rename.src_path = src_realpath; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1055 |
event->adt_ft_rename.dst_path = dst_realpath; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1056 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1057 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1058 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1059 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1060 |
MODRET solaris_audit_post_rnto(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1061 |
MODRET retval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1062 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1063 |
/* NULL means that there is no preceeding successfull RNFR command. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1064 |
if (src_path == NULL) |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1065 |
return PR_ERROR(cmd); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1066 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1067 |
retval = __solaris_audit_post(cmd, "RNTO", ADT_SUCCESS, ADT_SUCCESS, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1068 |
rnto_fill_event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1069 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1070 |
free(src_path); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1071 |
src_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1072 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1073 |
return retval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1074 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1075 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1076 |
/* It can happen, that RNTO command fails, but the destination path exists. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1077 |
* Therefore make an attempt to resolve its realpath before doing |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1078 |
* the audit log. |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1079 |
*/ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1080 |
static const char* rnto_err_fill_event(cmd_rec *cmd, adt_event_data_t *event) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1081 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1082 |
(void) realpath(event->adt_ft_rename.dst_path, dst_realpath); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1083 |
event->adt_ft_rename.src_path = src_realpath; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1084 |
event->adt_ft_rename.dst_path = dst_realpath; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1085 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1086 |
return NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1087 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1088 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1089 |
MODRET solaris_audit_post_rnto_err(cmd_rec *cmd) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1090 |
MODRET retval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1091 |
retval = __solaris_audit_post(cmd, "RNTO", ADT_FAILURE, ADT_FAILURE, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1092 |
rnto_err_fill_event); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1093 |
if (src_path != NULL) { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1094 |
free(src_path); |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1095 |
src_path = NULL; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1096 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1097 |
return retval; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1098 |
} |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1099 |
/* } RNTO. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1100 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1101 |
static cmdtable solaris_audit_commands[] = { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1102 |
/* Login, logout. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1103 |
{ POST_CMD, C_PASS, G_NONE, solaris_audit_post_pass, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1104 |
{ POST_CMD_ERR, C_PASS, G_NONE, solaris_audit_post_fail, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1105 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1106 |
/* Delete file. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1107 |
{ PRE_CMD, C_DELE, G_NONE, solaris_audit_pre_dele, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1108 |
{ POST_CMD, C_DELE, G_NONE, solaris_audit_post_dele, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1109 |
{ POST_CMD_ERR, C_DELE, G_NONE, solaris_audit_post_dele_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1110 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1111 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1112 |
/* Make directory. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1113 |
{ PRE_CMD, C_MKD, G_NONE, solaris_audit_pre_mkd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1114 |
{ POST_CMD, C_MKD, G_NONE, solaris_audit_post_mkd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1115 |
{ POST_CMD_ERR, C_MKD, G_NONE, solaris_audit_post_mkd_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1116 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1117 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1118 |
/* Remove directory. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1119 |
{ PRE_CMD, C_RMD, G_NONE, solaris_audit_pre_rmd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1120 |
{ POST_CMD, C_RMD, G_NONE, solaris_audit_post_rmd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1121 |
{ POST_CMD_ERR, C_RMD, G_NONE, solaris_audit_post_rmd_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1122 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1123 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1124 |
{ PRE_CMD, C_XRMD, G_NONE, solaris_audit_pre_rmd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1125 |
{ POST_CMD, C_XRMD, G_NONE, solaris_audit_post_rmd, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1126 |
{ POST_CMD_ERR, C_XRMD, G_NONE, solaris_audit_post_rmd_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1127 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1128 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1129 |
/* Get modification time. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1130 |
{ PRE_CMD, C_MDTM, G_NONE, solaris_audit_pre_mdtm, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1131 |
{ POST_CMD, C_MDTM, G_NONE, solaris_audit_post_mdtm, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1132 |
{ POST_CMD_ERR, C_MDTM, G_NONE, solaris_audit_post_mdtm_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1133 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1134 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1135 |
/* Upload file. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1136 |
{ PRE_CMD, C_STOR, G_WRITE, solaris_audit_pre_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1137 |
{ POST_CMD, C_STOR, G_WRITE, solaris_audit_post_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1138 |
{ POST_CMD_ERR, C_STOR, G_WRITE, solaris_audit_post_put_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1139 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1140 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1141 |
{ PRE_CMD, C_STOU, G_WRITE, solaris_audit_pre_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1142 |
{ POST_CMD, C_STOU, G_WRITE, solaris_audit_post_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1143 |
{ POST_CMD_ERR, C_STOU, G_WRITE, solaris_audit_post_put_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1144 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1145 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1146 |
{ PRE_CMD, C_APPE, G_WRITE, solaris_audit_pre_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1147 |
{ POST_CMD, C_APPE, G_WRITE, solaris_audit_post_put, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1148 |
{ POST_CMD_ERR, C_APPE, G_WRITE, solaris_audit_post_put_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1149 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1150 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1151 |
/* Download file. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1152 |
{ PRE_CMD, C_RETR, G_READ, solaris_audit_pre_get, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1153 |
{ POST_CMD, C_RETR, G_READ, solaris_audit_post_get, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1154 |
{ POST_CMD_ERR, C_RETR, G_READ, solaris_audit_post_get_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1155 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1156 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1157 |
/* Rename file. */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1158 |
{ PRE_CMD, C_RNFR, G_NONE, solaris_audit_pre_rnfr, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1159 |
{ POST_CMD, C_RNFR, G_NONE, solaris_audit_post_rnfr, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1160 |
{ POST_CMD_ERR, C_RNFR, G_NONE, solaris_audit_post_rnfr_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1161 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1162 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1163 |
{ PRE_CMD, C_RNTO, G_NONE, solaris_audit_pre_rnto, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1164 |
{ POST_CMD, C_RNTO, G_NONE, solaris_audit_post_rnto, FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1165 |
{ POST_CMD_ERR, C_RNTO, G_NONE, solaris_audit_post_rnto_err, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1166 |
FALSE, FALSE }, |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1167 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1168 |
{ 0, NULL } |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1169 |
}; |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1170 |
|
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1171 |
module solaris_audit_module = { |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1172 |
NULL, NULL, /* Always NULL */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1173 |
0x20, /* API Version 2.0 */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1174 |
"solaris_audit", |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1175 |
NULL, /* configuration table */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1176 |
solaris_audit_commands, /* command table is for local use only */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1177 |
NULL, /* No authentication handlers */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1178 |
NULL, /* No initialization function */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1179 |
audit_sess_init /* Post-fork "child mode" init */ |
e95b65443448
PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff
changeset
|
1180 |
}; |