]> oss.titaniummirror.com Git - repo_shell.git/blobdiff - git_acl.c
gitcreate doesn't add .git to file name
[repo_shell.git] / git_acl.c
index e077f785e54fd2a78e8e828ca1c3ab6a2e088068..796f5e96bd935b540e23196780b509917b3a658f 100644 (file)
--- a/git_acl.c
+++ b/git_acl.c
  */
 
 #include <stdbool.h>
-//#include <stdio.h>
-//#include <errno.h>
-//#include <stdlib.h>
-//#include <sys/types.h>
-//#include <fcntl.h>
-//#include <unistd.h>
-//#include <pwd.h>
+#include <stdlib.h>
 #include <string.h>
 #include "ini.h"
 #include "utility.h"
-#include "mystrtok.h"
+#include "stringutils.h"
 #include "stra.h"
 #include "git_acl.h"
 
@@ -114,23 +108,6 @@ static acl_clear(acl_t *acl)
   stra_destroy(&acl->userids);
 }
 
-static int str_has_word(const char* string, const char* word)
-{
-  char *_s = xstrdup(string);
-  char *s = _s;
-  char *p = my_strtok(&s, " \t\n");
-
-  while (p) {
-    if (!strcmp(p, word)) {
-      free(_s);
-      return true;
-    }
-    p = my_strtok(&s, " \t\n");
-  }
-  free(_s);
-  return false;
-}
-
 static int acl_handler(void* user, const char* section, const char* name,
     const char* value)
 {
@@ -159,8 +136,8 @@ static int acl_handler(void* user, const char* section, const char* name,
     if (!repo || my_strtok(&p, " \t\n"))
       die("acl_handler: badly formatted section '%s'", section);
     /* repo is repo name, name is userid, value is permission */
-    if (stra_find(&acl->repoids, repo) >= 0 &&
-        stra_find(&acl->userids, name) >= 0) {
+    if (stra_match(&acl->repoids, repo) >= 0 &&
+        stra_match(&acl->userids, name) >= 0) {
       acl->perms = perms_from_str(value);
       set_lm_repoid(repo);
       set_lm_userid(name);
@@ -174,13 +151,11 @@ static int acl_handler(void* user, const char* section, const char* name,
   return 1;
 }
 
-int git_acl(char *user, char *repo, char *file)
+int git_acl(const char *user, const char *repo, const char *file)
 {
   acl_t acl;
 
-  if (!file || !*file)
-    file = GIT_ACL_FILE;
-  if (!user || !*user || !repo || !*repo) {
+  if (!file || !*file || !user || !*user || !repo || !*repo) {
     die("git_acl: invalid args user='%s', repo='%s', file='%s'", user, repo,
        file);
   }
@@ -189,8 +164,8 @@ int git_acl(char *user, char *repo, char *file)
   set_lm_userid(NULL);
   lm_perms = PERMS_NOTFOUND;
   acl_init(&acl);
-  acl.user = user;
-  acl.repo = repo;
+  acl.user = (char*)user;
+  acl.repo = (char*)repo;
   stra_add(&acl.userids, acl.user);
   stra_add(&acl.repoids, acl.repo);