[BACK]Return to repository.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/repository.c between version 1.19 and 1.20

version 1.19, 2008/02/03 23:34:41 version 1.20, 2008/03/09 03:14:52
Line 41 
Line 41 
 }  }
   
 void  void
 cvs_repository_lock(const char *repo)  cvs_repository_lock(const char *repo, int wantlock)
 {  {
         int i;          int i;
           uid_t myuid;
         struct stat st;          struct stat st;
         char fpath[MAXPATHLEN];          char fpath[MAXPATHLEN];
         struct passwd *pw;          struct passwd *pw;
Line 51 
Line 52 
         if (cvs_noexec == 1 || cvs_readonlyfs == 1)          if (cvs_noexec == 1 || cvs_readonlyfs == 1)
                 return;                  return;
   
         cvs_log(LP_TRACE, "cvs_repository_lock(%s)", repo);          cvs_log(LP_TRACE, "cvs_repository_lock(%s, %d)", repo, wantlock);
   
         (void)xsnprintf(fpath, sizeof(fpath), "%s/%s", repo, CVS_LOCK);          (void)xsnprintf(fpath, sizeof(fpath), "%s/%s", repo, CVS_LOCK);
   
           myuid = getuid();
   
         for (i = 0; i < CVS_LOCK_TRIES; i++) {          for (i = 0; i < CVS_LOCK_TRIES; i++) {
                 if (cvs_quit)                  if (cvs_quit)
                         fatal("received signal %d", sig_received);                          fatal("received signal %d", sig_received);
Line 62 
Line 65 
                 if (stat(fpath, &st) == -1)                  if (stat(fpath, &st) == -1)
                         break;                          break;
   
                   if (st.st_uid == myuid)
                           return;
   
                 if ((pw = getpwuid(st.st_uid)) == NULL)                  if ((pw = getpwuid(st.st_uid)) == NULL)
                         fatal("cvs_repository_lock: %s", strerror(errno));                          fatal("cvs_repository_lock: %s", strerror(errno));
   
Line 72 
Line 78 
   
         if (i == CVS_LOCK_TRIES)          if (i == CVS_LOCK_TRIES)
                 fatal("maximum wait time for lock inside '%s' reached", repo);                  fatal("maximum wait time for lock inside '%s' reached", repo);
   
           if (wantlock == 0)
                   return;
   
         if ((i = open(fpath, O_WRONLY|O_CREAT|O_TRUNC, 0755)) < 0) {          if ((i = open(fpath, O_WRONLY|O_CREAT|O_TRUNC, 0755)) < 0) {
                 if (errno == EEXIST)                  if (errno == EEXIST)

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20