components/proftpd/patches/proftpd-error_code.patch
author Vladimir Marek <Vladimir.Marek@oracle.com>
Wed, 06 Nov 2013 22:31:34 +0100
branchs11u1-sru
changeset 2820 cdf3fd6228bc
parent 2734 d23b6301c400
child 1952 edbaa9c65514
permissions -rw-r--r--
15857036 pkg contents: slapd.conf overlay=allow requested
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     1
--- a/include/dirtree.h
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     2
+++ b/include/dirtree.h
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     3
@@ -113,6 +113,9 @@ typedef struct cmd_struc {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     4
   pr_table_t *notes;		/* Private data for passing/retaining between handlers */
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     5
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     6
   int cmd_id;			/* Index into commands list, for faster comparisons */
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     7
+  int error_code;               /* Stores errno of failed file transfer
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     8
+                                 * commands. Required for Solaris auditing.
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
     9
+                                 */
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    10
 } cmd_rec;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    11
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    12
 struct config_struc {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    13
diff --git a/modules/mod_core.c b/modules/mod_core.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    14
index ff400f6..18a47c2 100644
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    15
--- a/modules/mod_core.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    16
+++ b/modules/mod_core.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    17
@@ -4554,6 +4554,7 @@ MODRET core_rmd(cmd_rec *cmd) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    18
   dir = dir_canonical_path(cmd->tmp_pool, dir);
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    19
   if (dir == NULL) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    20
     int xerrno = EINVAL;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    21
+    cmd->error_code = EINVAL;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    22
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    23
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    24
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    25
@@ -4563,6 +4564,7 @@ MODRET core_rmd(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    26
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    27
   if (!dir_check_canon(cmd->tmp_pool, cmd, cmd->group, dir, NULL)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    28
     int xerrno = EACCES;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    29
+    cmd->error_code = EACCES;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    30
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    31
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    32
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    33
@@ -4572,6 +4574,7 @@ MODRET core_rmd(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    34
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    35
   if (pr_fsio_rmdir(dir) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    36
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    37
+    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
    38
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    39
     (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    40
       "error removing directory '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    41
@@ -4628,6 +4631,7 @@ MODRET core_mkd(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    42
   dir = dir_canonical_path(cmd->tmp_pool, dir);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    43
   if (dir == NULL) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    44
     int xerrno = EINVAL;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    45
+    cmd->error_code = EINVAL;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    46
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    47
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    48
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    49
@@ -4637,6 +4641,7 @@ MODRET core_mkd(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    50
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    51
   if (!dir_check_canon(cmd->tmp_pool, cmd, cmd->group, dir, NULL)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    52
     int xerrno = EACCES;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    53
+    cmd->error_code = EACCES;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    54
 
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    55
     pr_log_debug(DEBUG8, "%s command denied by <Limit> config", cmd->argv[0]);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    56
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    57
@@ -4648,6 +4653,7 @@ MODRET core_mkd(cmd_rec *cmd) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    58
   if (pr_fsio_smkdir(cmd->tmp_pool, dir, 0777, session.fsuid,
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    59
       session.fsgid) < 0) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    60
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    61
+    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
    62
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    63
     (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    64
       "error making directory '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    65
@@ -4694,6 +4700,7 @@ MODRET core_mdtm(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    66
       !dir_check(cmd->tmp_pool, cmd, cmd->group, path, NULL) ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    67
       pr_fsio_stat(path, &st) == -1) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    68
     int xerrno = errno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    69
+    cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    70
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    71
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    72
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    73
@@ -4805,6 +4812,7 @@ MODRET core_dele(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    74
   path = dir_canonical_path(cmd->tmp_pool, path);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    75
   if (path == NULL) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    76
     int xerrno = ENOENT;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    77
+    cmd->error_code = ENONET;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    78
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    79
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    80
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    81
@@ -4814,6 +4822,7 @@ MODRET core_dele(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    82
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    83
   if (!dir_check_canon(cmd->tmp_pool, cmd, cmd->group, path, NULL)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    84
     int xerrno = errno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    85
+    cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    86
 
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    87
     pr_log_debug(DEBUG7, "deleting '%s' denied by <Limit> configuration", path);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    88
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    89
@@ -4830,6 +4839,7 @@ MODRET core_dele(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    90
   pr_fs_clear_cache();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    91
   if (pr_fsio_lstat(path, &st) < 0) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    92
     int xerrno = errno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    93
+    cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    94
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    95
     pr_log_debug(DEBUG3, "unable to lstat '%s': %s", path, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    96
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
    97
@@ -4844,6 +4854,7 @@ MODRET core_dele(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    98
    */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
    99
   if (S_ISDIR(st.st_mode)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   100
     int xerrno = EISDIR;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   101
+    cmd->error_code = EISDIR;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   102
 
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   103
     (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   104
       "error deleting '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   105
@@ -4860,6 +4871,7 @@ MODRET core_dele(cmd_rec *cmd) {
305
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
   if (pr_fsio_unlink(path) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   108
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   109
+    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
   110
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   111
     (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   112
       "error deleting '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   113
@@ -4951,6 +4963,7 @@ MODRET core_rnto(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   114
       !dir_check_canon(cmd->tmp_pool, cmd, cmd->group, path, NULL) ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   115
       pr_fsio_rename(session.xfer.path, path) == -1) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   116
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   117
+    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
   118
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   119
     if (xerrno != EXDEV) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   120
       (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   121
@@ -4997,6 +5010,7 @@ MODRET core_rnto(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   122
      */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   123
     if (pr_fs_copy_file(session.xfer.path, path) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   124
       xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   125
+      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
   126
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   127
       (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   128
         "error copying '%s' to '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   129
@@ -5012,6 +5026,8 @@ MODRET core_rnto(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   130
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   131
     /* Once copied, unlink the original file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   132
     if (pr_fsio_unlink(session.xfer.path) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   133
+      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
   134
+
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   135
       pr_log_debug(DEBUG0, "error unlinking '%s': %s", session.xfer.path,
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   136
         strerror(errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   137
     }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   138
@@ -5069,6 +5085,7 @@ MODRET core_rnfr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   139
       !dir_check_canon(cmd->tmp_pool, cmd, cmd->group, path, NULL) ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   140
       !exists(path)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   141
     int xerrno = errno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   142
+    cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   143
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   144
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   145
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   146
diff --git a/modules/mod_xfer.c b/modules/mod_xfer.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   147
index c153bb3..762b542 100644
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   148
--- a/modules/mod_xfer.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   149
+++ b/modules/mod_xfer.c
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   150
@@ -1211,6 +1211,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
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
   if (cmd->argc < 2) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   153
     pr_response_add_err(R_500, _("'%s' not understood"), get_full_cmd(cmd));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   154
+    cmd->error_code = EINVAL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   155
     errno = EINVAL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   156
     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
   157
   }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   158
@@ -1221,6 +1222,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   159
   if (!path ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   160
       !dir_check(cmd->tmp_pool, cmd, cmd->group, path, NULL)) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   161
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   162
+    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
   163
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   164
     pr_log_debug(DEBUG8, "%s %s denied by <Limit> configuration", cmd->argv[0],
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   165
       cmd->arg);
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   166
@@ -1233,6 +1235,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   167
   if (xfer_check_limit(cmd) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   168
     pr_response_add_err(R_451, _("%s: Too many transfers"), cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   169
     errno = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   170
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   171
     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
   172
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   173
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   174
@@ -1245,6 +1248,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   175
     pr_log_debug(DEBUG6, "AllowOverwrite denied permission for %s", cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   176
     pr_response_add_err(R_550, _("%s: Overwrite permission denied"), cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   177
     errno = EACCES;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   178
+    cmd->error_code = EACCES;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   179
     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
   180
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   181
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   182
@@ -1268,6 +1272,8 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   183
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   184
       /* Deliberately use EISDIR for anything non-file (e.g. directories). */
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   185
       errno = EISDIR;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   186
+      cmd->error_code = EISDIR;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   187
+
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   188
       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
   189
     }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   190
   }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   191
@@ -1286,6 +1292,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   192
     session.restart_pos = 0L;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   193
     session.xfer.xfer_type = STOR_DEFAULT;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   194
     errno = EPERM;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   195
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   196
     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
   197
   }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   198
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   199
@@ -1304,9 +1311,11 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
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
   /* Otherwise everthing is good */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   202
   if (pr_table_add(cmd->notes, "mod_xfer.store-path",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   203
-      pstrdup(cmd->pool, path), 0) < 0)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   204
+      pstrdup(cmd->pool, path), 0) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   205
+    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
   206
     pr_log_pri(PR_LOG_NOTICE, "notice: error adding 'mod_xfer.store-path': %s",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   207
       strerror(errno));
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
   c = find_config(CURRENT_CONF, CONF_PARAM, "HiddenStores", FALSE);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   211
   if (c &&
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   212
@@ -1319,6 +1328,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   213
       pr_response_add_err(R_501,
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   214
         _("REST not compatible with server configuration"));
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   215
       errno = EINVAL;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   216
+      cmd->error_code = EINVAL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   217
       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
   218
     }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   219
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   220
@@ -1328,6 +1338,7 @@ MODRET xfer_pre_stor(cmd_rec *cmd) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   221
       pr_response_add_err(R_550,
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   222
         _("APPE not compatible with server configuration"));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   223
       errno = EINVAL;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   224
+      cmd->error_code = EINVAL;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   225
       return PR_ERROR(cmd);
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   226
     }
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   227
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   228
@@ -1391,6 +1402,7 @@ MODRET xfer_pre_stou(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   229
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   230
   tmpfd = mkstemp(filename);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   231
   if (tmpfd < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   232
+    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
   233
     pr_log_pri(PR_LOG_ERR, "error: unable to use mkstemp(): %s",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   234
       strerror(errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   235
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   236
@@ -1416,6 +1428,7 @@ MODRET xfer_pre_stou(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   237
   if (!filename ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   238
       !dir_check(cmd->tmp_pool, cmd, cmd->group, filename, NULL)) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   239
     int xerrno = errno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   240
+    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
   241
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   242
     /* Do not forget to delete the file created by mkstemp(3) if there is
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   243
      * an error.
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   244
@@ -1495,6 +1508,7 @@ MODRET xfer_pre_appe(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   245
   if (xfer_check_limit(cmd) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   246
     pr_response_add_err(R_451, _("%s: Too many transfers"), cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   247
     errno = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   248
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   249
     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
   250
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   251
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   252
@@ -1550,6 +1564,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   253
       O_WRONLY|(session.restart_pos ? 0 : O_CREAT|O_EXCL));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   254
     if (stor_fh == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   255
       ferrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   256
+      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
   257
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   258
       (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   259
         "error opening '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   260
@@ -1562,6 +1577,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
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
     if (stor_fh) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   263
       if (pr_fsio_lseek(stor_fh, 0, SEEK_END) == (off_t) -1) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   264
+        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
   265
         pr_log_debug(DEBUG4, "unable to seek to end of '%s' for appending: %s",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   266
           cmd->arg, strerror(errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   267
         (void) pr_fsio_close(stor_fh);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   268
@@ -1570,6 +1586,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   269
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   270
     } else {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   271
       ferrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   272
+      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
   273
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   274
       (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   275
         "error opening '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   276
@@ -1583,6 +1600,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   277
         O_WRONLY|(session.restart_pos ? 0 : O_TRUNC|O_CREAT));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   278
     if (stor_fh == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   279
       ferrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   280
+      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
   281
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   282
       (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   283
         "error opening '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   284
@@ -1596,11 +1614,13 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   285
     int xerrno = 0;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   286
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   287
     if (pr_fsio_lseek(stor_fh, session.restart_pos, SEEK_SET) == -1) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   288
+      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
   289
       pr_log_debug(DEBUG4, "unable to seek to position %" PR_LU " of '%s': %s",
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   290
         (pr_off_t) session.restart_pos, cmd->arg, strerror(errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   291
       xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   292
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   293
     } else if (pr_fsio_stat(path, &st) == -1) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   294
+      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
   295
       pr_log_debug(DEBUG4, "unable to stat '%s': %s", cmd->arg,
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   296
         strerror(errno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   297
       xerrno = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   298
@@ -1748,6 +1768,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   299
     res = pr_fsio_write(stor_fh, lbuf, len);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   300
     if (res != len) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   301
       int xerrno = EIO;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   302
+      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
   303
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   304
       if (res < 0)
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   305
         xerrno = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   306
@@ -1806,18 +1827,21 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   307
        */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   308
 #if defined(EDQUOT)
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   309
       if (xerrno == EDQUOT) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   310
+        cmd->error_code = EDQUOT;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   311
         pr_response_add_err(R_552, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   312
         errno = xerrno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   313
         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
   314
       }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   315
 #elif defined(EFBIG)
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   316
       if (xerrno == EFBIG) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   317
+        cmd->error_code = EFBIG;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   318
         pr_response_add_err(R_552, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   319
         errno = xerrno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   320
         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
   321
       }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   322
 #endif
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   323
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   324
+      cmd->error_code = EFBIG;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   325
       pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   326
       errno = xerrno;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   327
       return PR_ERROR(cmd);
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   328
@@ -1826,6 +1850,7 @@ MODRET xfer_stor(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   329
     if (session.xfer.path &&
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   330
         session.xfer.path_hidden) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   331
       if (pr_fsio_rename(session.xfer.path_hidden, session.xfer.path) != 0) {
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   332
+        cmd->error_code = errno;
305
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
         /* This should only fail on a race condition with a chmod/chown
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   335
          * or if STOR_APPEND is on and the permissions are squirrely.
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   336
@@ -1924,6 +1949,7 @@ MODRET xfer_pre_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   337
   if (cmd->argc < 2) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   338
     pr_response_add_err(R_500, _("'%s' not understood"), get_full_cmd(cmd));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   339
     errno = EINVAL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   340
+    cmd->error_code = EINVAL;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   341
     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
   342
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   343
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   344
@@ -1933,6 +1959,7 @@ MODRET xfer_pre_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   345
   if (!dir ||
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   346
       !dir_check(cmd->tmp_pool, cmd, cmd->group, dir, NULL)) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   347
     int xerrno = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   348
+    cmd->error_code = EINVAL;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   349
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   350
     pr_response_add_err(R_550, "%s: %s", cmd->arg, strerror(xerrno));
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   351
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   352
@@ -1955,6 +1982,7 @@ MODRET xfer_pre_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   353
   if (xfer_check_limit(cmd) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   354
     pr_response_add_err(R_451, _("%s: Too many transfers"), cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   355
     errno = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   356
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   357
     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
   358
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   359
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   360
@@ -1977,6 +2005,7 @@ MODRET xfer_pre_retr(cmd_rec *cmd) {
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   361
 
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   362
     /* Deliberately use EISDIR for anything non-file (e.g. directories). */
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   363
     errno = EISDIR;
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   364
+    cmd->error_code = EISDIR;
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   365
     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
   366
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   367
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   368
@@ -1991,6 +2020,7 @@ MODRET xfer_pre_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   369
       cmd->arg);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   370
     session.restart_pos = 0L;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   371
     errno = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   372
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   373
     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
   374
   }
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   375
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   376
@@ -2020,6 +2050,7 @@ MODRET xfer_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   377
   retr_fh = pr_fsio_open(dir, O_RDONLY);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   378
   if (retr_fh == NULL) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   379
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   380
+    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
   381
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   382
     (void) pr_trace_msg("fileperms", 1, "%s, user '%s' (UID %lu, GID %lu): "
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   383
       "error opening '%s': %s", cmd->argv[0], session.user,
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   384
@@ -2033,6 +2064,8 @@ MODRET xfer_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   385
   if (pr_fsio_stat(dir, &st) < 0) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   386
     /* Error stat'ing the file. */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   387
     int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   388
+    cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   389
+
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   390
     pr_fsio_close(retr_fh);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   391
     errno = xerrno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   392
 
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   393
@@ -2057,6 +2090,8 @@ MODRET xfer_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   394
     if (pr_fsio_lseek(retr_fh, session.restart_pos,
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   395
         SEEK_SET) == (off_t) -1) {
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   396
       int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   397
+      cmd->error_code = errno;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   398
+
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   399
       pr_fsio_close(retr_fh);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   400
       errno = xerrno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   401
       retr_fh = NULL;
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   402
@@ -2115,6 +2150,7 @@ MODRET xfer_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   403
     retr_abort();
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   404
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   405
     /* Set errno to EPERM ("Operation not permitted") */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   406
+    cmd->error_code = EPERM;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   407
     pr_data_abort(EPERM, FALSE);
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   408
     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
   409
   }
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   410
@@ -2146,6 +2182,7 @@ MODRET xfer_retr(cmd_rec *cmd) {
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   411
        * is preserved; errno itself might be overwritten in retr_abort().
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   412
        */
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   413
       int xerrno = errno;
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   414
+      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
   415
 
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   416
       retr_abort();
2734
d23b6301c400 16191277 problem in SERVICE/FTP-SERVER
Tomas Klacko <tomas.klacko@oracle.com>
parents: 305
diff changeset
   417
 
305
e95b65443448 PSARC 2011/088 Replace WU-ftpd with modern FTP server proftpd
Milan Jurik <Milan.Jurik@oracle.com>
parents:
diff changeset
   418