components/proftpd/mod_solaris_audit.c
author William.D.Johnston <William.D.Johnston@oracle.com>
Tue, 14 Jul 2015 12:09:08 -0700
branchs11-update
changeset 4646 2bb9a036a5f2
parent 598 398722c80922
permissions -rw-r--r--
20886490 proftpd can't open wtmpx after one login failure, doesn't register the ftp login 20717794 proftpd changes group ownership of file /etc/shadow after user login failure 19318572 root logins can't get all privilege when Solaris PrivilegeEngine enabled
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4646
2bb9a036a5f2 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: 598
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;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   114
  char *pwdbuf = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   115
  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
   116
  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
   117
  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
   118
  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
   119
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   120
  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
   121
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   122
    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
   123
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   124
  }
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
  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
   127
  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
   128
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   129
  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
   130
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   131
    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
   132
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   133
  }
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
  if ((authuser != NULL) && (authuser[0] != NULL) &&
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   136
    (getpwnam_r(authuser, &pwd, pwdbuf, pwdbuf_len) != NULL)) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   137
    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
   138
    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
   139
  } 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   140
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   141
  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
   142
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   143
    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
   144
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   145
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   146
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   147
  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
   148
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   149
    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
   150
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   151
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   152
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   153
  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
   154
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   155
    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
   156
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   157
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   158
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   159
  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
   160
  (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
   161
  asession = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   162
  return;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   163
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   164
fail:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   165
  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
   166
    strerror(saved_errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   167
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   168
  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
   169
  (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
   170
  asession = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   171
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   172
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   173
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
   174
  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
   175
  const char *how;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   176
  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
   177
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   178
  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
   179
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   180
    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
   181
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   182
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   183
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   184
  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
   185
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   186
    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
   187
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   188
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   189
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   190
  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
   191
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   192
    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
   193
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   194
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   195
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   196
  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
   197
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   198
  /* 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
   199
  return;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   200
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   201
fail:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   202
  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
   203
    strerror(saved_errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   204
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   205
  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
   206
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   207
  /* 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
   208
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   209
}
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
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
   212
  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
   213
  const char *how;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   214
  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
   215
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   216
  /* 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
   217
  if (asession == NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   218
    return;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   219
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   220
  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
   221
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   222
    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
   223
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   224
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   225
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   226
  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
   227
    saved_errno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   228
    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
   229
    goto fail;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   230
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   231
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   232
  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
   233
  (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
   234
  asession = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   235
  return;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   236
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   237
fail:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   238
  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
   239
    strerror(saved_errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   240
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   241
  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
   242
  (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
   243
  asession = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   244
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   245
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   246
/* Logout */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   247
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
   248
  audit_logout();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   249
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   250
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   251
/* Login passed */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   252
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
   253
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   254
  audit_success();
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
  /* 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
   257
  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
   258
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   259
  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
   260
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   261
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   262
/* Login failed */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   263
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
   264
  char *login_user;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   265
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   266
  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
   267
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   268
  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
   269
  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
   270
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   271
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   272
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
   273
  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
   274
  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
   275
  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
   276
  int rval = -1;					
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   277
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   278
  /* 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
   279
  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
   280
    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
   281
    return rval;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   282
  }
4646
2bb9a036a5f2 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: 598
diff changeset
   283
2bb9a036a5f2 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: 598
diff changeset
   284
  (void) getppriv(PRIV_INHERITABLE, privset);
2bb9a036a5f2 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: 598
diff changeset
   285
  priv_addset(privset, PRIV_PROC_AUDIT);
2bb9a036a5f2 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: 598
diff changeset
   286
  (void) setppriv(PRIV_SET, PRIV_INHERITABLE, privset);
2bb9a036a5f2 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: 598
diff changeset
   287
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   288
  (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
   289
  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
   290
  (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
   291
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   292
  /* 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
   293
  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
   294
    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
   295
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   296
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   297
  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
   298
    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
   299
    (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
   300
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   301
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   302
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   303
  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
   304
    ADT_SETTID) != 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   305
    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
   306
    free(termid);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   307
    (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
   308
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   309
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   310
  free(termid);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   311
  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
   312
    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
   313
    (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
   314
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   315
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   316
  (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
   317
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   318
  /* 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
   319
  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
   320
    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
   321
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   322
  rval = 0;
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
out:
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
  /* remove unneeded privileges */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   327
  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
   328
  (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
   329
  (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
   330
  priv_freeset(privset);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   331
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   332
  return rval;
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   335
#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
   336
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   337
/* 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
   338
 * 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
   339
 * {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   340
 */
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
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
   343
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
   344
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   345
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
 * 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
   348
 * 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
   349
 * 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
   350
 * 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
   351
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   352
 * 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
   353
 * 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
   354
 * 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
   355
 * 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
   356
 * (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
   357
 * 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
   358
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   359
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
   360
{
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   361
  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
   362
    "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
   363
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   364
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
 * 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
   367
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   368
 * 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
   369
 * 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
   370
 * 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
   371
 * 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
   372
 * structure.
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   373
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   374
 * 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
   375
 * 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
   376
 * 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
   377
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   378
 * 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
   379
 * 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
   380
 * 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
   381
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   382
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
   383
    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
   384
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   385
  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
   386
  const char *how = "";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   387
  char *tmp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   388
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   389
  /* 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
   390
   * 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
   391
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   392
  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
   393
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
   394
  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
   395
    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
   396
      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
   397
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   398
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   399
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   400
  if (arg2 != NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   401
    *arg2 = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   402
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
   403
    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
   404
      how = "no memory";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   405
      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
   406
        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
   407
      goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   408
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   409
    *arg2 = tmp;
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
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
   412
  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
   413
    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
   414
      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
   415
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   416
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   417
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   418
  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
   419
    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
   420
    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
   421
      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
   422
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   423
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   424
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
   425
  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
   426
    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
   427
    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
   428
      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
   429
    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
   430
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   431
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   432
  
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   433
  return event;
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
err:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   436
  return NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   437
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   438
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
 * 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
   441
 * 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
   442
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   443
 * 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
   444
 * 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
   445
 * __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
   446
 * 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   447
 * 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
   448
 * 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
   449
 * 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
   450
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   451
 * 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
   452
 * 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
   453
 * "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
   454
 * 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
   455
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   456
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
   457
  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
   458
  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
   459
{
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   460
  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
   461
  const char* how = "";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   462
  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
   463
  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
   464
  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
   465
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   466
  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
   467
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   468
    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
   469
    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
   470
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   471
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   472
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   473
  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
   474
    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
   475
    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
   476
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   477
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   478
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   479
  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
   480
    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
   481
    if (msg != NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   482
      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
   483
      goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   484
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   485
  }
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
  /* 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
   488
   * 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
   489
   * of the failure.
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   490
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   491
  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
   492
    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
   493
      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
   494
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   495
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   496
  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
   497
    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
   498
    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
   499
      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
   500
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   501
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   502
  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
   503
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   504
out:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   505
  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
   506
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   507
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
 * 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
   510
 * 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
   511
 * 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
   512
 * 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
   513
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   514
 * 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
   515
 * 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
   516
 * 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
   517
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   518
 * 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
   519
 * 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
   520
 * 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
   521
 * 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
   522
 * 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
   523
 * 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
   524
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   525
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
   526
(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   527
  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
   528
{
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   529
  struct stat64 *ptr;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   530
  int err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   531
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   532
  if (ret == NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   533
    return "NULL pointer";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   534
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   535
  *ret = NULL;
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
  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
   538
  if (ptr == NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   539
    return "no memory";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   540
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   541
  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
   542
  if (err == -1)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   543
    return "stat64() failed";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   544
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   545
  *ret = ptr;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   546
  return NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   547
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   548
/* } */
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
/* Delete file. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   552
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
   553
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   554
    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
   555
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   556
}
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
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
   559
  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
   560
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   561
  char* rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   562
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   563
  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
   564
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   565
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   566
    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
   567
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   568
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   569
  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
   570
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   571
    if (errno != ENOENT) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   572
      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
   573
        "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
   574
      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
   575
      error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   576
      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
   577
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   578
    /* 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
   579
     * 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
   580
     * 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
   581
     */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   582
  }
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
  if (rp != NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   585
    ptr = rp;    
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   586
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   587
  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
   588
  (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
   589
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   590
  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
   591
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   592
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   593
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
   594
  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
   595
    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
   596
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   597
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   598
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
   599
  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
   600
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   601
/* } */
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
/* Make directory. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   605
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
   606
  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
   607
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   608
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   609
  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
   610
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   611
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   612
    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
   613
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   614
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   615
  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
   616
  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
   617
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   618
  /* 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
   619
  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
   620
  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
   621
  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
   622
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   623
  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
   624
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   625
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   626
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
   627
  char *rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   628
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   629
  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
   630
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   631
    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
   632
    return "realpath() failed";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   633
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   634
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   635
  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
   636
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   637
    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
   638
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   639
}
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
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
   642
  char *rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   643
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   644
  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
   645
  if (rp != NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   646
    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
   647
    (void) __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   648
      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
   649
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   650
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   651
  return NULL;
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   654
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
   655
  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
   656
    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
   657
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   658
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   659
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
   660
  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
   661
    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
   662
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   663
/* } */
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
/* Remove directory. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   666
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
   667
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   668
    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
   669
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   670
}
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
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
   673
  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
   674
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   675
  char* rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   676
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   677
  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
   678
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   679
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   680
    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
   681
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   682
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   683
  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
   684
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   685
    if (errno != ENOENT) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   686
      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
   687
      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
   688
        "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
   689
      error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   690
      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
   691
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   692
  }
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
  if (rp != NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   695
    ptr = rp;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   696
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   697
  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
   698
  (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
   699
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   700
  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
   701
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   702
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   703
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
   704
  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
   705
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   706
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   707
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
   708
  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
   709
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   710
/* } */
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
/* 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
   713
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
   714
  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
   715
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   716
  char* rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   717
  
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   718
  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
   719
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   720
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   721
    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
   722
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   723
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   724
  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
   725
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   726
    if (errno != ENOENT) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   727
      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
   728
      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
   729
        "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
   730
      error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   731
      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
   732
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   733
  }
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
  if (rp != NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   736
    ptr = rp;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   737
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   738
  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
   739
  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
   740
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   741
  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
   742
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   743
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   744
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
   745
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   746
    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
   747
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   748
}
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
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
   751
  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
   752
    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
   753
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   754
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   755
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
   756
  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
   757
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   758
/* } */
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
/* Upload file. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   761
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
   762
  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
   763
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   764
  
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   765
  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
   766
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   767
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   768
    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
   769
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   770
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   771
  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
   772
  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
   773
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   774
  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
   775
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   776
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   777
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
   778
  char *rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   779
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   780
  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
   781
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   782
    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
   783
    return "realpath() failed";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   784
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   785
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   786
  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
   787
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   788
    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
   789
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   790
}
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
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
   793
  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
   794
    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
   795
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   796
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   797
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
   798
  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
   799
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   800
/* } */
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
/* Download file. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   803
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
   804
  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
   805
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   806
  char* rp = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   807
  
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   808
  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
   809
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   810
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   811
    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
   812
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   813
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   814
  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
   815
  if (rp == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   816
    if (errno != ENOENT) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   817
      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
   818
      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
   819
        "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
   820
      error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   821
      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
   822
    }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   823
  }
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
  if (rp != NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   826
    ptr = rp;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   827
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   828
  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
   829
  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
   830
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   831
  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
   832
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   833
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   834
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
   835
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   836
    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
   837
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   838
}
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
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
   841
  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
   842
    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
   843
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   844
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   845
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
   846
  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
   847
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   848
/* } */
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
/* Rename file. { */
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
 * 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
   853
 * 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
   854
 * 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   855
 * 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
   856
 * 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
   857
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   858
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
 * 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
   861
 * 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
   862
 * 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
   863
 * 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
   864
 * 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   865
 * 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
   866
 * 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
   867
 * 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
   868
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   869
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
   870
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   871
/* RNFR. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   872
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
   873
{
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   874
  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
   875
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   876
  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
   877
    return;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   878
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   879
  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
   880
  if (event == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   881
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   882
    goto out;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   883
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   884
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   885
  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
   886
  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
   887
  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
   888
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   889
  (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
   890
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   891
out:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   892
  free(src_path);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   893
  src_path = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   894
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   895
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   896
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
   897
  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
   898
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   899
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   900
  /*
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   901
   * 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
   902
   * 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
   903
   * 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
   904
   * 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
   905
   *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   906
   * 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
   907
   * 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
   908
   * 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
   909
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   910
  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
   911
    __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
   912
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   913
  /*
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   914
   * 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
   915
   * 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
   916
   * 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
   917
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   918
  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
   919
  if (event == NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   920
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   921
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   922
  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
   923
  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
   924
  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
   925
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
   926
  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
   927
  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
   928
    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
   929
      "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
   930
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   931
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   932
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   933
  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
   934
err:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   935
  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
   936
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   937
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
 * 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
   940
 * 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
   941
 * 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
   942
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   943
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
   944
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   945
  char *ptr;
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
  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
   948
  if (ptr == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   949
    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
   950
      "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
   951
    error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   952
    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
   953
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   954
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
   * 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
   957
   * 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
   958
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   959
  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
   960
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   961
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   962
/* 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
   963
 * 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
   964
 * the audit log.
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   965
 *
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   966
 * 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
   967
 * 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
   968
 * command handlers.
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   969
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   970
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
   971
  char *ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   972
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   973
  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
   974
    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
   975
    if (ptr != NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   976
      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
   977
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   978
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   979
  return NULL;
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
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
 * 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
   984
 * 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
   985
 * 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
   986
 * 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
   987
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   988
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
   989
  MODRET ret;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   990
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   991
  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
   992
    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
   993
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   994
  free(src_path);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   995
  src_path = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   996
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   997
  return ret;
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
/* } RNFR. */
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
/* RNTO. { */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1002
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
  1003
  return __fill_attr(
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1004
    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
  1005
  );
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1006
}
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
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
  1009
  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
  1010
  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
  1011
  char* ptr = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1012
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1013
  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
  1014
  if (event == NULL)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1015
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1016
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1017
  /*
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1018
   * 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
  1019
   * 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
  1020
   * 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
  1021
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1022
  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
  1023
  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
  1024
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1025
  /*
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1026
   * 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
  1027
   * 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
  1028
   * 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
  1029
   */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1030
  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
  1031
  if (msg != NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1032
    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
  1033
      "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
  1034
    goto err;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1035
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1036
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1037
  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
  1038
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1039
err:
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1040
  error_451();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1041
  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
  1042
}
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1043
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1044
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
  1045
  char *ptr;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1046
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1047
  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
  1048
  if (ptr == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1049
    return "realpath() failed";
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1050
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1051
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1052
  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
  1053
  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
  1054
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1055
  return NULL;
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1058
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
  1059
   MODRET retval;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1060
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1061
  /* 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
  1062
  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
  1063
    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
  1064
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1065
  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
  1066
    rnto_fill_event);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1067
  
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1068
  free(src_path);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1069
  src_path = NULL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1070
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1071
  return retval;
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1074
/* 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
  1075
 * 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
  1076
 * the audit log.
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1077
 */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1078
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
  1079
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1080
  (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
  1081
  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
  1082
  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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1084
  return NULL;
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1087
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
  1088
  MODRET retval;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1089
  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
  1090
    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
  1091
  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
  1092
    free(src_path);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1093
    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
  }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1095
  return retval;
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
/* } RNTO. */
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
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
  1100
    /* Login, logout. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1101
    { 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
  1102
    { 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
  1103
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1104
    /* Delete file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1105
    { 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
  1106
    { 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
  1107
    { 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
  1108
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1109
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1110
    /* Make directory. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1111
    { 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
  1112
    { 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
  1113
    { 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
  1114
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1115
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1116
    /* Remove directory. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1117
    { 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
  1118
    { 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
  1119
    { 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
  1120
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1121
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1122
    { 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
  1123
    { 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
  1124
    { 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
  1125
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1126
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1127
    /* Get modification time. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1128
    { 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
  1129
    { 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
  1130
    { 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
  1131
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1132
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1133
    /* Upload file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1134
    { 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
  1135
    { 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
  1136
    { 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
  1137
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1138
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1139
    { 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
  1140
    { 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
  1141
    { 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
  1142
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1143
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1144
    { 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
  1145
    { 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
  1146
    { 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
  1147
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1148
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1149
    /* Download file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1150
    { 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
  1151
    { 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
  1152
    { 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
  1153
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1154
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1155
    /* Rename file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1156
    { 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
  1157
    { 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
  1158
    { 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
  1159
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1160
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1161
    { 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
  1162
    { 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
  1163
    { 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
  1164
        FALSE, FALSE },
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1165
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1166
	{ 0, NULL }
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
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1169
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
  1170
	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
  1171
	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
  1172
	"solaris_audit",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1173
	NULL,			/* configuration table */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
  1174
	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
  1175
	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
  1176
	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
  1177
	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
  1178
};