Merge branch 'rs/maint-retval-fix' into maint
* rs/maint-retval-fix: merge-file: handle freopen() failure daemon: cleanup: factor out xstrdup_tolower() daemon: cleanup: replace loop with if daemon: handle freopen() failure
This commit is contained in:
commit
f611c8c0d1
@ -51,8 +51,11 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
|
|||||||
argc = parse_options(argc, argv, options, merge_file_usage, 0);
|
argc = parse_options(argc, argv, options, merge_file_usage, 0);
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
usage_with_options(merge_file_usage, options);
|
usage_with_options(merge_file_usage, options);
|
||||||
if (quiet)
|
if (quiet) {
|
||||||
freopen("/dev/null", "w", stderr);
|
if (!freopen("/dev/null", "w", stderr))
|
||||||
|
return error("failed to redirect stderr to /dev/null: "
|
||||||
|
"%s\n", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (!names[i])
|
if (!names[i])
|
||||||
|
56
daemon.c
56
daemon.c
@ -150,7 +150,6 @@ static char *path_ok(char *directory)
|
|||||||
{
|
{
|
||||||
static char rpath[PATH_MAX];
|
static char rpath[PATH_MAX];
|
||||||
static char interp_path[PATH_MAX];
|
static char interp_path[PATH_MAX];
|
||||||
int retried_path = 0;
|
|
||||||
char *path;
|
char *path;
|
||||||
char *dir;
|
char *dir;
|
||||||
|
|
||||||
@ -219,22 +218,15 @@ static char *path_ok(char *directory)
|
|||||||
dir = rpath;
|
dir = rpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
path = enter_repo(dir, strict_paths);
|
||||||
path = enter_repo(dir, strict_paths);
|
if (!path && base_path && base_path_relaxed) {
|
||||||
if (path)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if we fail and base_path_relaxed is enabled, try without
|
* if we fail and base_path_relaxed is enabled, try without
|
||||||
* prefixing the base path
|
* prefixing the base path
|
||||||
*/
|
*/
|
||||||
if (base_path && base_path_relaxed && !retried_path) {
|
dir = directory;
|
||||||
dir = directory;
|
path = enter_repo(dir, strict_paths);
|
||||||
retried_path = 1;
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
if (!path) {
|
if (!path) {
|
||||||
logerror("'%s': unable to chdir or not a git archive", dir);
|
logerror("'%s': unable to chdir or not a git archive", dir);
|
||||||
@ -405,6 +397,14 @@ static void make_service_overridable(const char *name, int ena)
|
|||||||
die("No such service %s", name);
|
die("No such service %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *xstrdup_tolower(const char *str)
|
||||||
|
{
|
||||||
|
char *p, *dup = xstrdup(str);
|
||||||
|
for (p = dup; *p; p++)
|
||||||
|
*p = tolower(*p);
|
||||||
|
return dup;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Separate the "extra args" information as supplied by the client connection.
|
* Separate the "extra args" information as supplied by the client connection.
|
||||||
*/
|
*/
|
||||||
@ -413,7 +413,6 @@ static void parse_extra_args(char *extra_args, int buflen)
|
|||||||
char *val;
|
char *val;
|
||||||
int vallen;
|
int vallen;
|
||||||
char *end = extra_args + buflen;
|
char *end = extra_args + buflen;
|
||||||
char *hp;
|
|
||||||
|
|
||||||
while (extra_args < end && *extra_args) {
|
while (extra_args < end && *extra_args) {
|
||||||
saw_extended_args = 1;
|
saw_extended_args = 1;
|
||||||
@ -431,7 +430,7 @@ static void parse_extra_args(char *extra_args, int buflen)
|
|||||||
tcp_port = xstrdup(port);
|
tcp_port = xstrdup(port);
|
||||||
}
|
}
|
||||||
free(hostname);
|
free(hostname);
|
||||||
hostname = xstrdup(host);
|
hostname = xstrdup_tolower(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On to the next one */
|
/* On to the next one */
|
||||||
@ -439,20 +438,11 @@ static void parse_extra_args(char *extra_args, int buflen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Replace literal host with lowercase-ized hostname.
|
|
||||||
*/
|
|
||||||
hp = hostname;
|
|
||||||
if (!hp)
|
|
||||||
return;
|
|
||||||
for ( ; *hp; hp++)
|
|
||||||
*hp = tolower(*hp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate canonical hostname and its IP address.
|
* Locate canonical hostname and its IP address.
|
||||||
*/
|
*/
|
||||||
|
if (hostname) {
|
||||||
#ifndef NO_IPV6
|
#ifndef NO_IPV6
|
||||||
{
|
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
struct addrinfo *ai, *ai0;
|
struct addrinfo *ai, *ai0;
|
||||||
int gai;
|
int gai;
|
||||||
@ -476,9 +466,7 @@ static void parse_extra_args(char *extra_args, int buflen)
|
|||||||
}
|
}
|
||||||
freeaddrinfo(ai0);
|
freeaddrinfo(ai0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
{
|
|
||||||
struct hostent *hent;
|
struct hostent *hent;
|
||||||
struct sockaddr_in sa;
|
struct sockaddr_in sa;
|
||||||
char **ap;
|
char **ap;
|
||||||
@ -499,8 +487,8 @@ static void parse_extra_args(char *extra_args, int buflen)
|
|||||||
canon_hostname = xstrdup(hent->h_name);
|
canon_hostname = xstrdup(hent->h_name);
|
||||||
free(ip_address);
|
free(ip_address);
|
||||||
ip_address = xstrdup(addrbuf);
|
ip_address = xstrdup(addrbuf);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -953,12 +941,8 @@ int main(int argc, char **argv)
|
|||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
|
|
||||||
if (!prefixcmp(arg, "--listen=")) {
|
if (!prefixcmp(arg, "--listen=")) {
|
||||||
char *p = arg + 9;
|
listen_addr = xstrdup_tolower(arg + 9);
|
||||||
char *ph = listen_addr = xmalloc(strlen(arg + 9) + 1);
|
continue;
|
||||||
while (*p)
|
|
||||||
*ph++ = tolower(*p++);
|
|
||||||
*ph = 0;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (!prefixcmp(arg, "--port=")) {
|
if (!prefixcmp(arg, "--port=")) {
|
||||||
char *end;
|
char *end;
|
||||||
@ -1118,7 +1102,9 @@ int main(int argc, char **argv)
|
|||||||
struct sockaddr *peer = (struct sockaddr *)&ss;
|
struct sockaddr *peer = (struct sockaddr *)&ss;
|
||||||
socklen_t slen = sizeof(ss);
|
socklen_t slen = sizeof(ss);
|
||||||
|
|
||||||
freopen("/dev/null", "w", stderr);
|
if (!freopen("/dev/null", "w", stderr))
|
||||||
|
die("failed to redirect stderr to /dev/null: %s",
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
if (getpeername(0, peer, &slen))
|
if (getpeername(0, peer, &slen))
|
||||||
peer = NULL;
|
peer = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user