]> TLD Linux GIT Repositories - packages/pure-ftpd.git/blob - pure-ftpd-pure-pw_passwd.patch
- add CAP_DAC_OVERRIDE
[packages/pure-ftpd.git] / pure-ftpd-pure-pw_passwd.patch
1 diff -Nura b.pure-ftpd-1.0.19/man/pure-pw.8 n.pure-ftpd-1.0.19/man/pure-pw.8
2 --- b.pure-ftpd-1.0.19/man/pure-pw.8    2004-07-21 00:23:25.000000000 +0200
3 +++ n.pure-ftpd-1.0.19/man/pure-pw.8    2004-07-21 00:31:10.000000000 +0200
4 @@ -5,7 +5,7 @@
5  .SH "SYNTAX"
6  .LP 
7  pure\-pw useradd login [\-f passwd_file] \-u uid [\-g gid]
8 -                \-D/\-d home_directory [\-c gecos]
9 +                \-D/\-d home_directory [\-c gecos] [\-p <password>]
10                  [\-t download_bandwidth] [\-T upload_bandwidth]
11                  [\-n max number_of_files] [\-N max_Mbytes]
12                  [\-q upload_ratio] [\-Q download_ratio]
13 @@ -15,7 +15,7 @@
14                  [\-z <hhmm>\-<hhmm>] [\-m]
15  .br 
16  pure\-pw usermod login \-f passwd_file \-u uid [\-g gid]
17 -                \-D/\-d home_directory \-[c gecos]
18 +                \-D/\-d home_directory \-[c gecos] [\-p <password>]
19                  [\-t download_bandwidth] [\-T upload_bandwidth]
20                  [\-n max_number_of_files] [\-N max_Mbytes]
21                  [\-q upload_ratio] [\-Q download_ratio]
22 diff -Nura b.pure-ftpd-1.0.19/src/pure-pw.c n.pure-ftpd-1.0.19/src/pure-pw.c
23 --- b.pure-ftpd-1.0.19/src/pure-pw.c    2004-07-21 00:23:25.000000000 +0200
24 +++ n.pure-ftpd-1.0.19/src/pure-pw.c    2004-07-21 00:32:08.000000000 +0200
25 @@ -25,6 +25,8 @@
26  static const char *random_device;
27  #endif
28  
29 +static char *cmdl_pass;
30 +
31  static void disable_echo(void)
32  {
33      if (!isatty(0)) {
34 @@ -163,7 +165,7 @@
35  {
36      puts("\nUsage :\n\n"
37           "pure-pw useradd <login> [-f <passwd file>] -u <uid> [-g <gid>]\n"
38 -         "                -D/-d <home directory> [-c <gecos>]\n"
39 +         "                -D/-d <home directory> [-c <gecos>] [-p <password>]\n"
40           "                [-t <download bandwidth>] [-T <upload bandwidth>]\n"
41           "                [-n <max number of files>] [-N <max Mbytes>]\n"
42           "                [-q <upload ratio>] [-Q <download ratio>]\n"
43 @@ -173,10 +175,10 @@
44           "                [-z <hhmm>-<hhmm>] [-m]\n"
45           "\n"
46           "pure-pw usermod <login> -f <passwd file> -u <uid> [-g <gid>]\n"
47 -         "                -D/-d <home directory> -[c <gecos>]\n"
48 +         "                -D/-d <home directory> -[c <gecos>] [-p <password>]\n"
49           "                [-t <download bandwidth>] [-T <upload bandwidth>]\n"
50           "                [-n <max number of files>] [-N <max Mbytes>]\n"
51 -         "                [-q <upload ratio>] [-Q <download ratio>]\n"
52 +         "                [-q <upload ratio>] [-Q <download ratio>] \n"
53           "                [-r <allow client ip>/<mask>] [-R <deny client ip>/<mask>]\n"
54           "                [-i <allow local ip>/<mask>] [-I <deny local ip>/<mask>]\n"
55       "                [-y <max number of concurrent sessions>]\n"     
56 @@ -701,12 +703,21 @@
57      return 0;
58  }
59  
60 -static char *do_get_passwd(void)
61 +static char *do_get_passwd(char *password)
62  {
63      static char pwd[LINE_MAX];
64      char pwd2[LINE_MAX];    
65      int tries = MAX_PASSWD_CHANGE_TRIES;
66 -       
67 +    if (password) {
68 +        size_t password_len = strlen(password);
69 +        if (password_len > LINE_MAX) {
70 +            puts("Supplied password is too long.");
71 +            return NULL;
72 +        } else {
73 +            memcpy((void *)pwd, (void *)password, password_len);
74 +            return password;
75 +        }
76 +    }
77      *pwd = 0;
78      *pwd2 = 0;
79      
80 @@ -813,7 +824,7 @@
81              no_mem();
82          }
83      }           
84 -    if ((pwinfo.pwd = do_get_passwd()) == NULL) {
85 +    if ((pwinfo.pwd = do_get_passwd(cmdl_pass)) == NULL) {
86          fprintf(stderr, "Error with entering password - aborting\n");        
87          return PW_ERROR_ENTER_PASSWD_PW_ERROR;
88      }
89 @@ -1157,7 +1168,7 @@
90          fprintf(stderr, "Missing passwd file\n");
91          return PW_ERROR_MISSING_PASSWD_FILE;
92      }
93 -    if ((pwinfo->pwd = do_get_passwd()) == NULL) {
94 +    if ((pwinfo->pwd = do_get_passwd(cmdl_pass)) == NULL) {
95          fprintf(stderr, "Error with entering password - aborting\n");        
96          return PW_ERROR_ENTER_PASSWD_PW_ERROR;
97      }    
98 @@ -1324,7 +1335,7 @@
99      }
100      filter_pw_line_sep(pwinfo.login);
101      while ((fodder = getopt(argc, argv, 
102 -                            "c:d:D:f:g:hi:I:mn:N:q:Q:r:R:t:T:u:y:z:")) != -1) {
103 +                            "c:d:D:f:g:hi:I:mn:N:p:q:Q:r:R:t:T:u:y:z:")) != -1) {
104          switch(fodder) {
105          case 'c' : {
106              if ((pwinfo.gecos = strdup(optarg)) == NULL) {
107 @@ -1422,6 +1433,12 @@
108              }
109              break;
110          }
111 +        case 'p' : {                      
112 +            if ((cmdl_pass = strdup(optarg)) == NULL) {
113 +                no_mem();
114 +            }
115 +            break;                                
116 +        }
117          case 'q' : {
118              if (*optarg == 0) {
119                  pwinfo.has_ul_ratio = -1;