]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - repo_shell.c
Remove unused code
[repo_shell.git] / repo_shell.c
index 1b06ec3eefbee2c2c49968db9ef61fc5f05af5f7..f92ce6ef1c804084e88f96f4d52c5b69557e0a83 100644 (file)
@@ -32,27 +32,7 @@ static cfg_t cfg {
 static cfg_t cfg;
 #endif
 
-#define alloc_nr(x) (((x)+16)*3/2)
-
-/*
- * Realloc the buffer pointed at by variable 'x' so that it can hold
- * at least 'nr' entries; the number of entries currently allocated
- * is 'alloc', using the standard growing factor alloc_nr() macro.
- *
- * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
- */
-#define ALLOC_GROW(x, nr, alloc) \
-       do { \
-               if ((nr) > alloc) { \
-                       if (alloc_nr(alloc) < (nr)) \
-                               alloc = (nr); \
-                       else \
-                               alloc = alloc_nr(alloc); \
-                       x = xrealloc((x), alloc * sizeof(*(x))); \
-               } \
-       } while (0)
-
-static inline void die(const char *fmt, ...)
+static void die(const char *fmt, ...)
 {
        va_list ap;
 
@@ -84,18 +64,6 @@ void *xmalloc(size_t size)
        return ret;
 }
 
-void *xrealloc(void *ptr, size_t size)
-{
-       void *ret;
-
-       ret = realloc(ptr, size);
-       if (!ret && !size)
-               ret = realloc(ptr, 1);
-       if (!ret)
-               die("Out of memory, realloc failed");
-       return ret;
-}
-
 static uid_t user_uid(char *user)
 {
        struct passwd *pw = getpwnam(user);
@@ -157,6 +125,7 @@ static int git_acl(const char *user, const char *repo)
         * access, a return of 1 means read only, and a return of 2 means
         * read/write.
         */
+#if 0
        struct passwd *pw;
        char *file;
        int len = strlen(cfg.owner) + strlen(GIT_ACL_FILE) + 8;
@@ -167,8 +136,9 @@ static int git_acl(const char *user, const char *repo)
        len = strlen(pw->pw_dir) + strlen(GIT_ACL_FILE) + 2;
        file = xmalloc(sizeof(char) * len);
        sprintf(file, "%s/%s", pw->pw_dir, GIT_ACL_FILE);
-       fprintf(stderr, "[someday check %s]\n", file);
+       fprintf(stderr, "[someday check %s for git ACLs]\n", file);
        free(file);
+#endif
        return 2; /* assume read/write for now */
 }
 
@@ -348,8 +318,10 @@ int main(int argc, char **argv)
                return 0;
        }
 
-       if (argc == 1 && check_ssh_interactive(getuid()))
+       if (argc == 1 && check_ssh_interactive(getuid())) {
+               setuid(getuid());
                execvp(shell_argv[0], (char *const *) shell_argv);
+        }
 
 #ifdef USE_DEFAULTS
        ini_parse("repo_shell.cfg", handler, &cfg);
@@ -388,6 +360,7 @@ int main(int argc, char **argv)
        if (!check_ssh_interactive(getuid()))
                die("only repository access is allowed");
 
+       setuid(getuid());
        cd_to_homedir();
        count = split_cmdline(prog, &user_argv);
        if (count >= 0) {