]> git.pld-linux.org Git - packages/pure-ftpd.git/blame - 0003-Allow-having-both-options-and-config-file-on-command.patch
Rel 5; pure-uploadscript retval has meaning only if it is enabled
[packages/pure-ftpd.git] / 0003-Allow-having-both-options-and-config-file-on-command.patch
CommitLineData
f543dc07
AM
1From f5617a4de54c313580fe39562f0d32e5c95f5212 Mon Sep 17 00:00:00 2001
2From: rpm-build <rpm-build>
3Date: Thu, 14 Sep 2017 01:05:53 +0200
4Subject: [PATCH] Allow having both options and config file on command line
5
6---
7 src/ftpd.c | 2 +-
8 src/simpleconf.c | 23 +++++++++++++++++++++--
9 2 files changed, 22 insertions(+), 3 deletions(-)
10
11diff --git a/src/ftpd.c b/src/ftpd.c
12index c5edac5..b13afc0 100644
13--- a/src/ftpd.c
14+++ b/src/ftpd.c
15@@ -5589,7 +5589,7 @@ int pureftpd_start(int argc, char *argv[], const char *home_directory_)
16 #endif
17
18 #ifndef MINIMAL
19- if (argc == 2 && *argv[1] != '-' &&
20+ if (argc >= 2 && *argv[1] != '-' &&
21 sc_build_command_line_from_file(argv[1], NULL, simpleconf_options,
22 (sizeof simpleconf_options) /
23 (sizeof simpleconf_options[0]),
24diff --git a/src/simpleconf.c b/src/simpleconf.c
25index f296f54..505aee1 100644
26--- a/src/simpleconf.c
27+++ b/src/simpleconf.c
28@@ -674,9 +674,10 @@ sc_build_command_line_from_file(const char *file_name,
29 {
30 char **argv = NULL;
31 int argc = 0;
32+ char **argv_tmp = NULL;
33+ char *arg = NULL;
34+ int i;
35
36- *argc_p = 0;
37- *argv_p = NULL;
38 if ((argv = malloc(sizeof *argv)) == NULL ||
39 (app_name = strdup(app_name)) == NULL) {
40 sc_argv_free(argc, argv);
41@@ -689,6 +690,24 @@ sc_build_command_line_from_file(const char *file_name,
42 sc_argv_free(argc, argv);
43 return -1;
44 }
45+
46+ for (i = 2; i < *argc_p; ++i) {
47+ ++argc;
48+ arg = strdup((*argv_p)[i]);
49+ if (arg == NULL) {
50+ return -1;
51+ }
52+ if ((argv_tmp = realloc(argv, (sizeof arg) *
53+ ((size_t) argc + 1))) == NULL) {
54+ return -1;
55+ }
56+ argv = argv_tmp;
57+ argv[argc - 1] = arg;
58+ }
59+ if (*argc_p > 2) {
60+ argv[argc] = NULL;
61+ }
62+
63 *argc_p = argc;
64 *argv_p = argv;
65
66--
672.9.5
68
This page took 0.71982 seconds and 4 git commands to generate.