static char *add_prefix(char *prefix, char* arg)
{
- int size;
-
- if (arg && prefix && strlen(prefix)) {
- char *n = xmalloc(sizeof(char *) *
- (strlen(prefix) + strlen(arg) + 2));
- strcpy(n, prefix);
- strcat(n, "/");
- strcat(n, arg);
- arg = n;
+ char *narg = arg;
+ int i;
+
+ if (arg && prefix && (i = strlen(prefix))) {
+ narg = xmalloc(sizeof(char *) * (i + strlen(arg) + 2));
+ strcpy(narg, prefix);
+ strcpy(narg + i++, "/");
+ strcpy(narg + i, arg);
}
- return arg;
+ return narg;
}
static int check_ssh_interactive(uid_t uid)
static int git_check_access(const char *cmd, const char *repo, const char *user)
{
- int rw = 1; /* 0=no access, 1=read only, 2=read/write */
-
- /* What access is required per the incoming command? */
- if (!strcmp(cmd, "git-upload-pack") ||
- !strcmp(cmd, "git-upload-archive"))
- rw = 2;
+ /* What access is required per the incoming command?
+ * 0=none, 1=read-only, 2=read-write
+ */
+ int rw = (!strcmp(cmd, "git-upload-pack") ||
+ !strcmp(cmd, "git-upload-archive")) ? 2 : 1;
/* Return true (1) if the user permissions >= those required */
return (git_acl(user, repo) >= rw) ? 1 : 0;
{
const char *home = getenv("HOME");
if (!home)
- die("could not determine user's home directory; HOME is unset");
+ die("user variable HOME is unset");
if (chdir(home) == -1)
die("could not chdir to user's home directory");
}