CVS user mapping patch .. 2th

얼마전 올렸던 usermap patch 의 버그 수정입니다. 이전 패치에서 usermap 파일이 없을 경우 에러가 발생하는 문제가 있었습니다. 파일이 없으면 CVS_FOPEN 이 에러가 발생할 것이라는 엄청난 착각을 한 결과이네요. 이런저런 경우의 수를 다해서 테스트를 했다고 생각했는데..

diff -urNp cvs-1.11.17.org/src/server.c cvs-1.11.17/src/server.c --- cvs-1.11.17.org/src/server.c 2006-09-13 17:35:21.000000000 +0900 +++ cvs-1.11.17/src/server.c 2006-09-13 18:07:24.000000000 +0900 @@ -5785,7 +5785,56 @@ handle_return: It might or might not be the same as host_user. */ CVS_Username = xmalloc (strlen (username) + 1); strcpy (CVS_Username, username); - } + + if ( ! strcmp (username, host_user) ) { + char filename[256] = { 0, }; + FILE *op; + int userlen = strlen (username); + char *linebuf = NULL; + size_t linebuf_len; + struct stat mapfile; + sprintf (filename, "%s/%s/usermap", repository, CVSROOTADM); + + //syslog (LOG_DAEMON | LOG_NOTICE, "oops: %s", filename); + + if ( CVS_STAT (filename, &mapfile) > -1 ) { + if ( (op = CVS_FOPEN (filename, "r")) != NULL ) { + while ( getline (&linebuf, &linebuf_len, op) >= 0 ) { + if ( (strncmp (linebuf, username, userlen) == 0) + && (linebuf[userlen] == ':') ) { + char *mapuser = NULL; + char *ws = NULL; + char mapuserlen = 0; + + mapuser = strchr (linebuf, ':'); + if ( (ws = strchr (mapuser, ' ')) ) + mapuser[ws - mapuser] = 0; + else if ( (ws = strchr (mapuser, '\t')) ) + mapuser[ws - mapuser] = 0; + else if ( (ws = strchr (mapuser, '\r')) ) + mapuser[ws - mapuser] = 0; + else if ( (ws = strchr (mapuser, '\n')) ) + mapuser[ws - mapuser] = 0; + + mapuserlen = strlen (mapuser) - 1; + if ( mapuserlen > 0 ) { + free (host_user); + host_user = xstrdup (mapuser + 1); + } + break; + } + } + } + if (linebuf) free (linebuf); + + if ( ferror (op) ) + error (0, errno, "cannot read %s", filename); + + if ( fclose (op) < 0 ) + error (0, errno, "cannot close %s", filename); + } + } + } return host_user; }

Posted by 김정균

2006/09/13 19:47 2006/09/13 19:47
, ,
Response
No Trackback , No Comment
RSS :
http://my.oops.org/rss/response/82

Trackback URL : http://my.oops.org/trackback/82

Leave a comment
[로그인][오픈아이디란?]
« Previous : 1 : ... 31 : 32 : 33 : 34 : 35 : 36 : 37 : 38 : 39 : ... 108 : Next »

Valid XHTML 1.0 Transitional Valid CSS 2.0!
뭘 이런걸..

뭘 이런걸..

Notices

Categories

전체 (108)
군이 (11)
주절주절 (21)
Tech (76)

Calendar

«   2008/11   »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

Site Stats