Fossil SCM

merge trunk. Fix behavior of "Brancing" checkbox, and simplify javascript functions.

jan.nijtmans 2013-12-14 09:24 hidden-tag merge
Commit 885d72b2bd59067d31de3c966db049e2d6c4f287
4 files changed +1 -2 +221 -5 +23 -35 +23 -35
+1 -2
--- src/clone.c
+++ src/clone.c
@@ -121,10 +121,11 @@
121121
int bPrivate = 0; /* Also clone private branches */
122122
int urlFlags = URL_PROMPT_PW | URL_REMEMBER;
123123
124124
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
125125
if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
126
+ zDefaultUser = find_option("admin-user","A",1);
126127
clone_ssh_find_options();
127128
url_proxy_options();
128129
if( g.argc < 4 ){
129130
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
130131
}
@@ -131,12 +132,10 @@
131132
db_open_config(0);
132133
if( file_size(g.argv[3])>0 ){
133134
fossil_fatal("file already exists: %s", g.argv[3]);
134135
}
135136
136
- zDefaultUser = find_option("admin-user","A",1);
137
-
138137
url_parse(g.argv[2], urlFlags);
139138
if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
140139
if( g.urlIsFile ){
141140
file_copy(g.urlName, g.argv[3]);
142141
db_close(1);
143142
--- src/clone.c
+++ src/clone.c
@@ -121,10 +121,11 @@
121 int bPrivate = 0; /* Also clone private branches */
122 int urlFlags = URL_PROMPT_PW | URL_REMEMBER;
123
124 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
125 if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
 
126 clone_ssh_find_options();
127 url_proxy_options();
128 if( g.argc < 4 ){
129 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
130 }
@@ -131,12 +132,10 @@
131 db_open_config(0);
132 if( file_size(g.argv[3])>0 ){
133 fossil_fatal("file already exists: %s", g.argv[3]);
134 }
135
136 zDefaultUser = find_option("admin-user","A",1);
137
138 url_parse(g.argv[2], urlFlags);
139 if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
140 if( g.urlIsFile ){
141 file_copy(g.urlName, g.argv[3]);
142 db_close(1);
143
--- src/clone.c
+++ src/clone.c
@@ -121,10 +121,11 @@
121 int bPrivate = 0; /* Also clone private branches */
122 int urlFlags = URL_PROMPT_PW | URL_REMEMBER;
123
124 if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
125 if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
126 zDefaultUser = find_option("admin-user","A",1);
127 clone_ssh_find_options();
128 url_proxy_options();
129 if( g.argc < 4 ){
130 usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
131 }
@@ -131,12 +132,10 @@
132 db_open_config(0);
133 if( file_size(g.argv[3])>0 ){
134 fossil_fatal("file already exists: %s", g.argv[3]);
135 }
136
 
 
137 url_parse(g.argv[2], urlFlags);
138 if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
139 if( g.urlIsFile ){
140 file_copy(g.urlName, g.argv[3]);
141 db_close(1);
142
+221 -5
--- src/file.c
+++ src/file.c
@@ -47,11 +47,16 @@
4747
** Use _stati64 rather than stat on windows, in order to handle files
4848
** larger than 2GB.
4949
*/
5050
#if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
5151
# undef stat
52
-# define stat _stati64
52
+# define stat _fossil_stati64
53
+struct stat {
54
+ i64 st_size;
55
+ i64 st_mtime;
56
+ int st_mode;
57
+};
5358
#endif
5459
/*
5560
** On Windows S_ISLNK always returns FALSE.
5661
*/
5762
#if !defined(S_ISLNK)
@@ -73,12 +78,22 @@
7378
rc = lstat(zMbcs, buf);
7479
}else{
7580
rc = stat(zMbcs, buf);
7681
}
7782
#else
83
+ WIN32_FILE_ATTRIBUTE_DATA attr;
7884
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
79
- rc = _wstati64(zMbcs, buf);
85
+ rc = !GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr);
86
+ if( !rc ){
87
+ ULARGE_INTEGER ull;
88
+ ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
89
+ ull.HighPart = attr.ftLastWriteTime.dwHighDateTime;
90
+ buf->st_mode = (attr.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)?
91
+ S_IFDIR:S_IFREG;
92
+ buf->st_size = (((i64)attr.nFileSizeHigh)<<32) | attr.nFileSizeLow;
93
+ buf->st_mtime = ull.QuadPart / 10000000ULL - 11644473600ULL;
94
+ }
8095
#endif
8196
fossil_filename_free(zMbcs);
8297
return rc;
8398
}
8499
@@ -303,12 +318,213 @@
303318
/*
304319
** Wrapper around the access() system call.
305320
*/
306321
int file_access(const char *zFilename, int flags){
307322
#ifdef _WIN32
323
+ SECURITY_DESCRIPTOR *sdPtr = NULL;
324
+ unsigned long size;
325
+ PSID pSid = 0;
326
+ BOOL SidDefaulted;
327
+ SID_IDENTIFIER_AUTHORITY samba_unmapped = {{0, 0, 0, 0, 0, 22}};
328
+ GENERIC_MAPPING genMap;
329
+ HANDLE hToken = NULL;
330
+ DWORD desiredAccess = 0, grantedAccess = 0;
331
+ BOOL accessYesNo = FALSE;
332
+ PRIVILEGE_SET privSet;
333
+ DWORD privSetSize = sizeof(PRIVILEGE_SET);
334
+ int rc = 0;
335
+ DWORD attr;
308336
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309
- int rc = _waccess(zMbcs, flags);
337
+
338
+ attr = GetFileAttributesW(zMbcs);
339
+
340
+ if( attr==INVALID_FILE_ATTRIBUTES ){
341
+ /*
342
+ * File might not exist.
343
+ */
344
+
345
+ if( GetLastError()!=ERROR_SHARING_VIOLATION ){
346
+ fossil_filename_free(zMbcs);
347
+ return -1;
348
+ }
349
+ }
350
+
351
+ if( flags==F_OK ){
352
+ /*
353
+ * File exists, nothing else to check.
354
+ */
355
+
356
+ fossil_filename_free(zMbcs);
357
+ return 0;
358
+ }
359
+
360
+ if( (flags & W_OK)
361
+ && (attr & FILE_ATTRIBUTE_READONLY)
362
+ && !(attr & FILE_ATTRIBUTE_DIRECTORY) ){
363
+ /*
364
+ * The attributes say the file is not writable. If the file is a
365
+ * regular file (i.e., not a directory), then the file is not
366
+ * writable, full stop. For directories, the read-only bit is
367
+ * (mostly) ignored by Windows, so we can't ascertain anything about
368
+ * directory access from the attrib data. However, if we have the
369
+ * advanced 'getFileSecurityProc', then more robust ACL checks
370
+ * will be done below.
371
+ */
372
+
373
+ fossil_filename_free(zMbcs);
374
+ return -1;
375
+ }
376
+
377
+ /*
378
+ * It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
379
+ * we have a more complex permissions structure so we try to check that.
380
+ * The code below is remarkably complex for such a simple thing as finding
381
+ * what permissions the OS has set for a file.
382
+ */
383
+
384
+ /*
385
+ * First find out how big the buffer needs to be.
386
+ */
387
+
388
+ size = 0;
389
+ GetFileSecurityW(zMbcs,
390
+ OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
391
+ | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
392
+ 0, 0, &size);
393
+
394
+ /*
395
+ * Should have failed with ERROR_INSUFFICIENT_BUFFER
396
+ */
397
+
398
+ if( GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
399
+ /*
400
+ * Most likely case is ERROR_ACCESS_DENIED, which we will convert
401
+ * to EACCES - just what we want!
402
+ */
403
+
404
+ fossil_filename_free(zMbcs);
405
+ return -1;
406
+ }
407
+
408
+ /*
409
+ * Now size contains the size of buffer needed.
410
+ */
411
+
412
+ sdPtr = (SECURITY_DESCRIPTOR *) HeapAlloc(GetProcessHeap(), 0, size);
413
+
414
+ if( sdPtr == NULL ){
415
+ goto accessError;
416
+ }
417
+
418
+ /*
419
+ * Call GetFileSecurity() for real.
420
+ */
421
+
422
+ if( !GetFileSecurityW(zMbcs,
423
+ OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
424
+ | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
425
+ sdPtr, size, &size) ){
426
+ /*
427
+ * Error getting owner SD
428
+ */
429
+
430
+ goto accessError;
431
+ }
432
+
433
+ /*
434
+ * As of Samba 3.0.23 (10-Jul-2006), unmapped users and groups are
435
+ * assigned to SID domains S-1-22-1 and S-1-22-2, where "22" is the
436
+ * top-level authority. If the file owner and group is unmapped then
437
+ * the ACL access check below will only test against world access,
438
+ * which is likely to be more restrictive than the actual access
439
+ * restrictions. Since the ACL tests are more likely wrong than
440
+ * right, skip them. Moreover, the unix owner access permissions are
441
+ * usually mapped to the Windows attributes, so if the user is the
442
+ * file owner then the attrib checks above are correct (as far as they
443
+ * go).
444
+ */
445
+
446
+ if( !GetSecurityDescriptorOwner(sdPtr,&pSid,&SidDefaulted) ||
447
+ memcmp(GetSidIdentifierAuthority(pSid),&samba_unmapped,
448
+ sizeof(SID_IDENTIFIER_AUTHORITY))==0 ){
449
+ HeapFree(GetProcessHeap(), 0, sdPtr);
450
+ fossil_filename_free(zMbcs);
451
+ return 0; /* Attrib tests say access allowed. */
452
+ }
453
+
454
+ /*
455
+ * Perform security impersonation of the user and open the resulting
456
+ * thread token.
457
+ */
458
+
459
+ if( !ImpersonateSelf(SecurityImpersonation) ){
460
+ /*
461
+ * Unable to perform security impersonation.
462
+ */
463
+
464
+ goto accessError;
465
+ }
466
+ if( !OpenThreadToken(GetCurrentThread(),
467
+ TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken) ){
468
+ /*
469
+ * Unable to get current thread's token.
470
+ */
471
+
472
+ goto accessError;
473
+ }
474
+
475
+ RevertToSelf();
476
+
477
+ /*
478
+ * Setup desiredAccess according to the access priveleges we are
479
+ * checking.
480
+ */
481
+
482
+ if( flags & R_OK ){
483
+ desiredAccess |= FILE_GENERIC_READ;
484
+ }
485
+ if( flags & W_OK){
486
+ desiredAccess |= FILE_GENERIC_WRITE;
487
+ }
488
+
489
+ memset(&genMap, 0x0, sizeof(GENERIC_MAPPING));
490
+ genMap.GenericRead = FILE_GENERIC_READ;
491
+ genMap.GenericWrite = FILE_GENERIC_WRITE;
492
+ genMap.GenericExecute = FILE_GENERIC_EXECUTE;
493
+ genMap.GenericAll = FILE_ALL_ACCESS;
494
+
495
+ /*
496
+ * Perform access check using the token.
497
+ */
498
+
499
+ if( !AccessCheck(sdPtr, hToken, desiredAccess,
500
+ &genMap, &privSet, &privSetSize, &grantedAccess,
501
+ &accessYesNo) ){
502
+ /*
503
+ * Unable to perform access check.
504
+ */
505
+
506
+ accessError:
507
+ if( sdPtr != NULL ){
508
+ HeapFree(GetProcessHeap(), 0, sdPtr);
509
+ }
510
+ if( hToken != NULL ){
511
+ CloseHandle(hToken);
512
+ }
513
+ fossil_filename_free(zMbcs);
514
+ return -1;
515
+ }
516
+
517
+ /*
518
+ * Clean up.
519
+ */
520
+
521
+ HeapFree(GetProcessHeap(), 0, sdPtr);
522
+ CloseHandle(hToken);
523
+ if( !accessYesNo ){
524
+ rc = -1;
525
+ }
310526
#else
311527
char *zMbcs = fossil_utf8_to_filename(zFilename);
312528
int rc = access(zMbcs, flags);
313529
#endif
314530
fossil_filename_free(zMbcs);
@@ -321,11 +537,11 @@
321537
** (UNIX only)
322538
*/
323539
int file_chdir(const char *zChDir, int bChroot){
324540
#ifdef _WIN32
325541
wchar_t *zPath = fossil_utf8_to_filename(zChDir);
326
- int rc = _wchdir(zPath);
542
+ int rc = SetCurrentDirectoryW(zPath)==0;
327543
#else
328544
char *zPath = fossil_utf8_to_filename(zChDir);
329545
int rc = chdir(zPath);
330546
if( !rc && bChroot ){
331547
rc = chroot(zPath);
@@ -728,11 +944,11 @@
728944
#ifdef _WIN32
729945
char *zPwdUtf8;
730946
int nPwd;
731947
int i;
732948
wchar_t zPwd[2000];
733
- if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
949
+ if( GetCurrentDirectoryW(count(zPwd), zPwd)==0 ){
734950
fossil_fatal("cannot find the current working directory.");
735951
}
736952
zPwdUtf8 = fossil_filename_to_utf8(zPwd);
737953
nPwd = strlen(zPwdUtf8);
738954
if( nPwd > nBuf-1 ){
739955
--- src/file.c
+++ src/file.c
@@ -47,11 +47,16 @@
47 ** Use _stati64 rather than stat on windows, in order to handle files
48 ** larger than 2GB.
49 */
50 #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
51 # undef stat
52 # define stat _stati64
 
 
 
 
 
53 #endif
54 /*
55 ** On Windows S_ISLNK always returns FALSE.
56 */
57 #if !defined(S_ISLNK)
@@ -73,12 +78,22 @@
73 rc = lstat(zMbcs, buf);
74 }else{
75 rc = stat(zMbcs, buf);
76 }
77 #else
 
78 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
79 rc = _wstati64(zMbcs, buf);
 
 
 
 
 
 
 
 
 
80 #endif
81 fossil_filename_free(zMbcs);
82 return rc;
83 }
84
@@ -303,12 +318,213 @@
303 /*
304 ** Wrapper around the access() system call.
305 */
306 int file_access(const char *zFilename, int flags){
307 #ifdef _WIN32
 
 
 
 
 
 
 
 
 
 
 
 
 
308 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
309 int rc = _waccess(zMbcs, flags);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310 #else
311 char *zMbcs = fossil_utf8_to_filename(zFilename);
312 int rc = access(zMbcs, flags);
313 #endif
314 fossil_filename_free(zMbcs);
@@ -321,11 +537,11 @@
321 ** (UNIX only)
322 */
323 int file_chdir(const char *zChDir, int bChroot){
324 #ifdef _WIN32
325 wchar_t *zPath = fossil_utf8_to_filename(zChDir);
326 int rc = _wchdir(zPath);
327 #else
328 char *zPath = fossil_utf8_to_filename(zChDir);
329 int rc = chdir(zPath);
330 if( !rc && bChroot ){
331 rc = chroot(zPath);
@@ -728,11 +944,11 @@
728 #ifdef _WIN32
729 char *zPwdUtf8;
730 int nPwd;
731 int i;
732 wchar_t zPwd[2000];
733 if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
734 fossil_fatal("cannot find the current working directory.");
735 }
736 zPwdUtf8 = fossil_filename_to_utf8(zPwd);
737 nPwd = strlen(zPwdUtf8);
738 if( nPwd > nBuf-1 ){
739
--- src/file.c
+++ src/file.c
@@ -47,11 +47,16 @@
47 ** Use _stati64 rather than stat on windows, in order to handle files
48 ** larger than 2GB.
49 */
50 #if defined(_WIN32) && (defined(__MSVCRT__) || defined(_MSC_VER))
51 # undef stat
52 # define stat _fossil_stati64
53 struct stat {
54 i64 st_size;
55 i64 st_mtime;
56 int st_mode;
57 };
58 #endif
59 /*
60 ** On Windows S_ISLNK always returns FALSE.
61 */
62 #if !defined(S_ISLNK)
@@ -73,12 +78,22 @@
78 rc = lstat(zMbcs, buf);
79 }else{
80 rc = stat(zMbcs, buf);
81 }
82 #else
83 WIN32_FILE_ATTRIBUTE_DATA attr;
84 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
85 rc = !GetFileAttributesExW(zMbcs, GetFileExInfoStandard, &attr);
86 if( !rc ){
87 ULARGE_INTEGER ull;
88 ull.LowPart = attr.ftLastWriteTime.dwLowDateTime;
89 ull.HighPart = attr.ftLastWriteTime.dwHighDateTime;
90 buf->st_mode = (attr.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)?
91 S_IFDIR:S_IFREG;
92 buf->st_size = (((i64)attr.nFileSizeHigh)<<32) | attr.nFileSizeLow;
93 buf->st_mtime = ull.QuadPart / 10000000ULL - 11644473600ULL;
94 }
95 #endif
96 fossil_filename_free(zMbcs);
97 return rc;
98 }
99
@@ -303,12 +318,213 @@
318 /*
319 ** Wrapper around the access() system call.
320 */
321 int file_access(const char *zFilename, int flags){
322 #ifdef _WIN32
323 SECURITY_DESCRIPTOR *sdPtr = NULL;
324 unsigned long size;
325 PSID pSid = 0;
326 BOOL SidDefaulted;
327 SID_IDENTIFIER_AUTHORITY samba_unmapped = {{0, 0, 0, 0, 0, 22}};
328 GENERIC_MAPPING genMap;
329 HANDLE hToken = NULL;
330 DWORD desiredAccess = 0, grantedAccess = 0;
331 BOOL accessYesNo = FALSE;
332 PRIVILEGE_SET privSet;
333 DWORD privSetSize = sizeof(PRIVILEGE_SET);
334 int rc = 0;
335 DWORD attr;
336 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
337
338 attr = GetFileAttributesW(zMbcs);
339
340 if( attr==INVALID_FILE_ATTRIBUTES ){
341 /*
342 * File might not exist.
343 */
344
345 if( GetLastError()!=ERROR_SHARING_VIOLATION ){
346 fossil_filename_free(zMbcs);
347 return -1;
348 }
349 }
350
351 if( flags==F_OK ){
352 /*
353 * File exists, nothing else to check.
354 */
355
356 fossil_filename_free(zMbcs);
357 return 0;
358 }
359
360 if( (flags & W_OK)
361 && (attr & FILE_ATTRIBUTE_READONLY)
362 && !(attr & FILE_ATTRIBUTE_DIRECTORY) ){
363 /*
364 * The attributes say the file is not writable. If the file is a
365 * regular file (i.e., not a directory), then the file is not
366 * writable, full stop. For directories, the read-only bit is
367 * (mostly) ignored by Windows, so we can't ascertain anything about
368 * directory access from the attrib data. However, if we have the
369 * advanced 'getFileSecurityProc', then more robust ACL checks
370 * will be done below.
371 */
372
373 fossil_filename_free(zMbcs);
374 return -1;
375 }
376
377 /*
378 * It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
379 * we have a more complex permissions structure so we try to check that.
380 * The code below is remarkably complex for such a simple thing as finding
381 * what permissions the OS has set for a file.
382 */
383
384 /*
385 * First find out how big the buffer needs to be.
386 */
387
388 size = 0;
389 GetFileSecurityW(zMbcs,
390 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
391 | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
392 0, 0, &size);
393
394 /*
395 * Should have failed with ERROR_INSUFFICIENT_BUFFER
396 */
397
398 if( GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
399 /*
400 * Most likely case is ERROR_ACCESS_DENIED, which we will convert
401 * to EACCES - just what we want!
402 */
403
404 fossil_filename_free(zMbcs);
405 return -1;
406 }
407
408 /*
409 * Now size contains the size of buffer needed.
410 */
411
412 sdPtr = (SECURITY_DESCRIPTOR *) HeapAlloc(GetProcessHeap(), 0, size);
413
414 if( sdPtr == NULL ){
415 goto accessError;
416 }
417
418 /*
419 * Call GetFileSecurity() for real.
420 */
421
422 if( !GetFileSecurityW(zMbcs,
423 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
424 | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
425 sdPtr, size, &size) ){
426 /*
427 * Error getting owner SD
428 */
429
430 goto accessError;
431 }
432
433 /*
434 * As of Samba 3.0.23 (10-Jul-2006), unmapped users and groups are
435 * assigned to SID domains S-1-22-1 and S-1-22-2, where "22" is the
436 * top-level authority. If the file owner and group is unmapped then
437 * the ACL access check below will only test against world access,
438 * which is likely to be more restrictive than the actual access
439 * restrictions. Since the ACL tests are more likely wrong than
440 * right, skip them. Moreover, the unix owner access permissions are
441 * usually mapped to the Windows attributes, so if the user is the
442 * file owner then the attrib checks above are correct (as far as they
443 * go).
444 */
445
446 if( !GetSecurityDescriptorOwner(sdPtr,&pSid,&SidDefaulted) ||
447 memcmp(GetSidIdentifierAuthority(pSid),&samba_unmapped,
448 sizeof(SID_IDENTIFIER_AUTHORITY))==0 ){
449 HeapFree(GetProcessHeap(), 0, sdPtr);
450 fossil_filename_free(zMbcs);
451 return 0; /* Attrib tests say access allowed. */
452 }
453
454 /*
455 * Perform security impersonation of the user and open the resulting
456 * thread token.
457 */
458
459 if( !ImpersonateSelf(SecurityImpersonation) ){
460 /*
461 * Unable to perform security impersonation.
462 */
463
464 goto accessError;
465 }
466 if( !OpenThreadToken(GetCurrentThread(),
467 TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken) ){
468 /*
469 * Unable to get current thread's token.
470 */
471
472 goto accessError;
473 }
474
475 RevertToSelf();
476
477 /*
478 * Setup desiredAccess according to the access priveleges we are
479 * checking.
480 */
481
482 if( flags & R_OK ){
483 desiredAccess |= FILE_GENERIC_READ;
484 }
485 if( flags & W_OK){
486 desiredAccess |= FILE_GENERIC_WRITE;
487 }
488
489 memset(&genMap, 0x0, sizeof(GENERIC_MAPPING));
490 genMap.GenericRead = FILE_GENERIC_READ;
491 genMap.GenericWrite = FILE_GENERIC_WRITE;
492 genMap.GenericExecute = FILE_GENERIC_EXECUTE;
493 genMap.GenericAll = FILE_ALL_ACCESS;
494
495 /*
496 * Perform access check using the token.
497 */
498
499 if( !AccessCheck(sdPtr, hToken, desiredAccess,
500 &genMap, &privSet, &privSetSize, &grantedAccess,
501 &accessYesNo) ){
502 /*
503 * Unable to perform access check.
504 */
505
506 accessError:
507 if( sdPtr != NULL ){
508 HeapFree(GetProcessHeap(), 0, sdPtr);
509 }
510 if( hToken != NULL ){
511 CloseHandle(hToken);
512 }
513 fossil_filename_free(zMbcs);
514 return -1;
515 }
516
517 /*
518 * Clean up.
519 */
520
521 HeapFree(GetProcessHeap(), 0, sdPtr);
522 CloseHandle(hToken);
523 if( !accessYesNo ){
524 rc = -1;
525 }
526 #else
527 char *zMbcs = fossil_utf8_to_filename(zFilename);
528 int rc = access(zMbcs, flags);
529 #endif
530 fossil_filename_free(zMbcs);
@@ -321,11 +537,11 @@
537 ** (UNIX only)
538 */
539 int file_chdir(const char *zChDir, int bChroot){
540 #ifdef _WIN32
541 wchar_t *zPath = fossil_utf8_to_filename(zChDir);
542 int rc = SetCurrentDirectoryW(zPath)==0;
543 #else
544 char *zPath = fossil_utf8_to_filename(zChDir);
545 int rc = chdir(zPath);
546 if( !rc && bChroot ){
547 rc = chroot(zPath);
@@ -728,11 +944,11 @@
944 #ifdef _WIN32
945 char *zPwdUtf8;
946 int nPwd;
947 int i;
948 wchar_t zPwd[2000];
949 if( GetCurrentDirectoryW(count(zPwd), zPwd)==0 ){
950 fossil_fatal("cannot find the current working directory.");
951 }
952 zPwdUtf8 = fossil_filename_to_utf8(zPwd);
953 nPwd = strlen(zPwdUtf8);
954 if( nPwd > nBuf-1 ){
955
+23 -35
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
22062206
blob_append(&comment, zNewComment, -1);
22072207
zUuid[10] = 0;
22082208
style_header("Edit Check-in [%s]", zUuid);
22092209
/*
22102210
** Javascript functions to assist in modifying hidden branch options.
2211
- ** stcbi: sets the textContent for the given element id to val
2212
- ** usids: updates SPAN ids that contain the branch IDs
2211
+ ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2212
+ ** remaining of form.
22132213
*/
22142214
@ <script>
2215
- @ function stcbi(id,val){
2216
- @ if( id ) id.textContent = val;
2215
+ @ function chgcbn(checked, branch){
2216
+ @ val = gebi('brname').value;
2217
+ @ if( !val || !checked) val = branch;
2218
+ @ gebi('hbranch').textContent = val;
2219
+ @ cidbrid = document.getElementById('cbranch');
2220
+ @ if( cidbrid ) cidbrid.textContent = val;
22172221
@ }
2218
- @ function usids(zdef,formid,toggle){
2219
- @ hidbrid = gebi('hbranch');
2222
+ @ function chgbn(val, branch){
2223
+ @ if( !val ) val = branch;
2224
+ @ gebi('newbr').checked = (val!=branch);
2225
+ @ gebi('hbranch').textContent = val;
22202226
@ cidbrid = document.getElementById('cbranch');
2221
- @ if( toggle ){
2222
- @ stcbi(hidbrid,zdef);
2223
- @ stcbi(cidbrid,zdef);
2224
- @ }else{
2225
- @ newvalue = gebi(formid).value;
2226
- @ if( newvalue ){
2227
- @ stcbi(hidbrid,newvalue);
2228
- @ stcbi(cidbrid,newvalue);
2229
- @ }
2230
- @ }
2227
+ @ if( cidbrid ) cidbrid.textContent = val;
22312228
@ }
22322229
@ </script>
22332230
if( P("preview") ){
22342231
Blob suffix;
22352232
int nTag = 0;
@@ -2349,42 +2346,33 @@
23492346
}
23502347
}
23512348
db_finalize(&q);
23522349
@ </td></tr>
23532350
2351
+ if( !zBranchName ){
2352
+ zBranchName = db_get("main-branch", "trunk");
2353
+ }
2354
+ if( !zNewBranch || !zNewBranch[0]){
2355
+ zNewBranch = zBranchName;
2356
+ }
23542357
@ <tr><th align="right" valign="top">Branching:</th>
23552358
@ <td valign="top">
23562359
@ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2357
- if( !fHasHidden && zBranchName ){
2358
- @ onclick="usids('%h(zBranchName)','brname',this.value)"
2359
- }
2360
- @ />
2360
+ @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
23612361
@ Make this check-in the start of a new branch named:</label>
2362
- @ <input type="text" style="width:15;" id="brname" name="brname"
2362
+ @ <input id="brname" type="text" style="width:15;" name="brname"
23632363
@ value="%h(zNewBranch)"
2364
- if( !fHasHidden && zBranchName ){
2365
- @ onkeyup="f=!!this.value
2366
- if( zBranchName ){
2367
- @ if(f)f=this.value!='%h(zBranchName)'
2368
- }
2369
- @ gebi('newbr').checked=f
2370
- @ usids('%h(zBranchName)','brname',!f)"
2371
- }
2372
- @ />
2373
- @ </td></tr>
2374
-
2375
- if( !fHasHidden && zBranchName ){
2364
+ @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2365
+ if( !fHasHidden ){
23762366
@ <tr><th align="right" valign="top">Branch Hiding:</th>
23772367
@ <td valign="top">
23782368
@ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
23792369
@ Hide branch
23802370
@ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
23812371
@ from the timeline starting from this check-in</label>
23822372
@ </td></tr>
23832373
}
2384
-
2385
-
23862374
if( !fHasClosed ){
23872375
if( is_a_leaf(rid) ){
23882376
@ <tr><th align="right" valign="top">Leaf Closure:</th>
23892377
@ <td valign="top">
23902378
@ <label><input type="checkbox" name="close"%s(zCloseFlag) />
23912379
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
2206 blob_append(&comment, zNewComment, -1);
2207 zUuid[10] = 0;
2208 style_header("Edit Check-in [%s]", zUuid);
2209 /*
2210 ** Javascript functions to assist in modifying hidden branch options.
2211 ** stcbi: sets the textContent for the given element id to val
2212 ** usids: updates SPAN ids that contain the branch IDs
2213 */
2214 @ <script>
2215 @ function stcbi(id,val){
2216 @ if( id ) id.textContent = val;
 
 
 
 
2217 @ }
2218 @ function usids(zdef,formid,toggle){
2219 @ hidbrid = gebi('hbranch');
 
 
2220 @ cidbrid = document.getElementById('cbranch');
2221 @ if( toggle ){
2222 @ stcbi(hidbrid,zdef);
2223 @ stcbi(cidbrid,zdef);
2224 @ }else{
2225 @ newvalue = gebi(formid).value;
2226 @ if( newvalue ){
2227 @ stcbi(hidbrid,newvalue);
2228 @ stcbi(cidbrid,newvalue);
2229 @ }
2230 @ }
2231 @ }
2232 @ </script>
2233 if( P("preview") ){
2234 Blob suffix;
2235 int nTag = 0;
@@ -2349,42 +2346,33 @@
2349 }
2350 }
2351 db_finalize(&q);
2352 @ </td></tr>
2353
 
 
 
 
 
 
2354 @ <tr><th align="right" valign="top">Branching:</th>
2355 @ <td valign="top">
2356 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2357 if( !fHasHidden && zBranchName ){
2358 @ onclick="usids('%h(zBranchName)','brname',this.value)"
2359 }
2360 @ />
2361 @ Make this check-in the start of a new branch named:</label>
2362 @ <input type="text" style="width:15;" id="brname" name="brname"
2363 @ value="%h(zNewBranch)"
2364 if( !fHasHidden && zBranchName ){
2365 @ onkeyup="f=!!this.value
2366 if( zBranchName ){
2367 @ if(f)f=this.value!='%h(zBranchName)'
2368 }
2369 @ gebi('newbr').checked=f
2370 @ usids('%h(zBranchName)','brname',!f)"
2371 }
2372 @ />
2373 @ </td></tr>
2374
2375 if( !fHasHidden && zBranchName ){
2376 @ <tr><th align="right" valign="top">Branch Hiding:</th>
2377 @ <td valign="top">
2378 @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
2379 @ Hide branch
2380 @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
2381 @ from the timeline starting from this check-in</label>
2382 @ </td></tr>
2383 }
2384
2385
2386 if( !fHasClosed ){
2387 if( is_a_leaf(rid) ){
2388 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2389 @ <td valign="top">
2390 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2391
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
2206 blob_append(&comment, zNewComment, -1);
2207 zUuid[10] = 0;
2208 style_header("Edit Check-in [%s]", zUuid);
2209 /*
2210 ** Javascript functions to assist in modifying hidden branch options.
2211 ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2212 ** remaining of form.
2213 */
2214 @ <script>
2215 @ function chgcbn(checked, branch){
2216 @ val = gebi('brname').value;
2217 @ if( !val || !checked) val = branch;
2218 @ gebi('hbranch').textContent = val;
2219 @ cidbrid = document.getElementById('cbranch');
2220 @ if( cidbrid ) cidbrid.textContent = val;
2221 @ }
2222 @ function chgbn(val, branch){
2223 @ if( !val ) val = branch;
2224 @ gebi('newbr').checked = (val!=branch);
2225 @ gebi('hbranch').textContent = val;
2226 @ cidbrid = document.getElementById('cbranch');
2227 @ if( cidbrid ) cidbrid.textContent = val;
 
 
 
 
 
 
 
 
 
2228 @ }
2229 @ </script>
2230 if( P("preview") ){
2231 Blob suffix;
2232 int nTag = 0;
@@ -2349,42 +2346,33 @@
2346 }
2347 }
2348 db_finalize(&q);
2349 @ </td></tr>
2350
2351 if( !zBranchName ){
2352 zBranchName = db_get("main-branch", "trunk");
2353 }
2354 if( !zNewBranch || !zNewBranch[0]){
2355 zNewBranch = zBranchName;
2356 }
2357 @ <tr><th align="right" valign="top">Branching:</th>
2358 @ <td valign="top">
2359 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2360 @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
 
 
 
2361 @ Make this check-in the start of a new branch named:</label>
2362 @ <input id="brname" type="text" style="width:15;" name="brname"
2363 @ value="%h(zNewBranch)"
2364 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2365 if( !fHasHidden ){
 
 
 
 
 
 
 
 
 
 
2366 @ <tr><th align="right" valign="top">Branch Hiding:</th>
2367 @ <td valign="top">
2368 @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
2369 @ Hide branch
2370 @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
2371 @ from the timeline starting from this check-in</label>
2372 @ </td></tr>
2373 }
 
 
2374 if( !fHasClosed ){
2375 if( is_a_leaf(rid) ){
2376 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2377 @ <td valign="top">
2378 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2379
+23 -35
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
22062206
blob_append(&comment, zNewComment, -1);
22072207
zUuid[10] = 0;
22082208
style_header("Edit Check-in [%s]", zUuid);
22092209
/*
22102210
** Javascript functions to assist in modifying hidden branch options.
2211
- ** stcbi: sets the textContent for the given element id to val
2212
- ** usids: updates SPAN ids that contain the branch IDs
2211
+ ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2212
+ ** remaining of form.
22132213
*/
22142214
@ <script>
2215
- @ function stcbi(id,val){
2216
- @ if( id ) id.textContent = val;
2215
+ @ function chgcbn(checked, branch){
2216
+ @ val = gebi('brname').value;
2217
+ @ if( !val || !checked) val = branch;
2218
+ @ gebi('hbranch').textContent = val;
2219
+ @ cidbrid = document.getElementById('cbranch');
2220
+ @ if( cidbrid ) cidbrid.textContent = val;
22172221
@ }
2218
- @ function usids(zdef,formid,toggle){
2219
- @ hidbrid = gebi('hbranch');
2222
+ @ function chgbn(val, branch){
2223
+ @ if( !val ) val = branch;
2224
+ @ gebi('newbr').checked = (val!=branch);
2225
+ @ gebi('hbranch').textContent = val;
22202226
@ cidbrid = document.getElementById('cbranch');
2221
- @ if( toggle ){
2222
- @ stcbi(hidbrid,zdef);
2223
- @ stcbi(cidbrid,zdef);
2224
- @ }else{
2225
- @ newvalue = gebi(formid).value;
2226
- @ if( newvalue ){
2227
- @ stcbi(hidbrid,newvalue);
2228
- @ stcbi(cidbrid,newvalue);
2229
- @ }
2230
- @ }
2227
+ @ if( cidbrid ) cidbrid.textContent = val;
22312228
@ }
22322229
@ </script>
22332230
if( P("preview") ){
22342231
Blob suffix;
22352232
int nTag = 0;
@@ -2349,42 +2346,33 @@
23492346
}
23502347
}
23512348
db_finalize(&q);
23522349
@ </td></tr>
23532350
2351
+ if( !zBranchName ){
2352
+ zBranchName = db_get("main-branch", "trunk");
2353
+ }
2354
+ if( !zNewBranch || !zNewBranch[0]){
2355
+ zNewBranch = zBranchName;
2356
+ }
23542357
@ <tr><th align="right" valign="top">Branching:</th>
23552358
@ <td valign="top">
23562359
@ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2357
- if( !fHasHidden && zBranchName ){
2358
- @ onclick="usids('%h(zBranchName)','brname',this.value)"
2359
- }
2360
- @ />
2360
+ @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
23612361
@ Make this check-in the start of a new branch named:</label>
2362
- @ <input type="text" style="width:15;" id="brname" name="brname"
2362
+ @ <input id="brname" type="text" style="width:15;" name="brname"
23632363
@ value="%h(zNewBranch)"
2364
- if( !fHasHidden && zBranchName ){
2365
- @ onkeyup="f=!!this.value
2366
- if( zBranchName ){
2367
- @ if(f)f=this.value!='%h(zBranchName)'
2368
- }
2369
- @ gebi('newbr').checked=f
2370
- @ usids('%h(zBranchName)','brname',!f)"
2371
- }
2372
- @ />
2373
- @ </td></tr>
2374
-
2375
- if( !fHasHidden && zBranchName ){
2364
+ @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2365
+ if( !fHasHidden ){
23762366
@ <tr><th align="right" valign="top">Branch Hiding:</th>
23772367
@ <td valign="top">
23782368
@ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
23792369
@ Hide branch
23802370
@ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
23812371
@ from the timeline starting from this check-in</label>
23822372
@ </td></tr>
23832373
}
2384
-
2385
-
23862374
if( !fHasClosed ){
23872375
if( is_a_leaf(rid) ){
23882376
@ <tr><th align="right" valign="top">Leaf Closure:</th>
23892377
@ <td valign="top">
23902378
@ <label><input type="checkbox" name="close"%s(zCloseFlag) />
23912379
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
2206 blob_append(&comment, zNewComment, -1);
2207 zUuid[10] = 0;
2208 style_header("Edit Check-in [%s]", zUuid);
2209 /*
2210 ** Javascript functions to assist in modifying hidden branch options.
2211 ** stcbi: sets the textContent for the given element id to val
2212 ** usids: updates SPAN ids that contain the branch IDs
2213 */
2214 @ <script>
2215 @ function stcbi(id,val){
2216 @ if( id ) id.textContent = val;
 
 
 
 
2217 @ }
2218 @ function usids(zdef,formid,toggle){
2219 @ hidbrid = gebi('hbranch');
 
 
2220 @ cidbrid = document.getElementById('cbranch');
2221 @ if( toggle ){
2222 @ stcbi(hidbrid,zdef);
2223 @ stcbi(cidbrid,zdef);
2224 @ }else{
2225 @ newvalue = gebi(formid).value;
2226 @ if( newvalue ){
2227 @ stcbi(hidbrid,newvalue);
2228 @ stcbi(cidbrid,newvalue);
2229 @ }
2230 @ }
2231 @ }
2232 @ </script>
2233 if( P("preview") ){
2234 Blob suffix;
2235 int nTag = 0;
@@ -2349,42 +2346,33 @@
2349 }
2350 }
2351 db_finalize(&q);
2352 @ </td></tr>
2353
 
 
 
 
 
 
2354 @ <tr><th align="right" valign="top">Branching:</th>
2355 @ <td valign="top">
2356 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2357 if( !fHasHidden && zBranchName ){
2358 @ onclick="usids('%h(zBranchName)','brname',this.value)"
2359 }
2360 @ />
2361 @ Make this check-in the start of a new branch named:</label>
2362 @ <input type="text" style="width:15;" id="brname" name="brname"
2363 @ value="%h(zNewBranch)"
2364 if( !fHasHidden && zBranchName ){
2365 @ onkeyup="f=!!this.value
2366 if( zBranchName ){
2367 @ if(f)f=this.value!='%h(zBranchName)'
2368 }
2369 @ gebi('newbr').checked=f
2370 @ usids('%h(zBranchName)','brname',!f)"
2371 }
2372 @ />
2373 @ </td></tr>
2374
2375 if( !fHasHidden && zBranchName ){
2376 @ <tr><th align="right" valign="top">Branch Hiding:</th>
2377 @ <td valign="top">
2378 @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
2379 @ Hide branch
2380 @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
2381 @ from the timeline starting from this check-in</label>
2382 @ </td></tr>
2383 }
2384
2385
2386 if( !fHasClosed ){
2387 if( is_a_leaf(rid) ){
2388 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2389 @ <td valign="top">
2390 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2391
--- src/info.c
+++ src/info.c
@@ -2206,30 +2206,27 @@
2206 blob_append(&comment, zNewComment, -1);
2207 zUuid[10] = 0;
2208 style_header("Edit Check-in [%s]", zUuid);
2209 /*
2210 ** Javascript functions to assist in modifying hidden branch options.
2211 ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2212 ** remaining of form.
2213 */
2214 @ <script>
2215 @ function chgcbn(checked, branch){
2216 @ val = gebi('brname').value;
2217 @ if( !val || !checked) val = branch;
2218 @ gebi('hbranch').textContent = val;
2219 @ cidbrid = document.getElementById('cbranch');
2220 @ if( cidbrid ) cidbrid.textContent = val;
2221 @ }
2222 @ function chgbn(val, branch){
2223 @ if( !val ) val = branch;
2224 @ gebi('newbr').checked = (val!=branch);
2225 @ gebi('hbranch').textContent = val;
2226 @ cidbrid = document.getElementById('cbranch');
2227 @ if( cidbrid ) cidbrid.textContent = val;
 
 
 
 
 
 
 
 
 
2228 @ }
2229 @ </script>
2230 if( P("preview") ){
2231 Blob suffix;
2232 int nTag = 0;
@@ -2349,42 +2346,33 @@
2346 }
2347 }
2348 db_finalize(&q);
2349 @ </td></tr>
2350
2351 if( !zBranchName ){
2352 zBranchName = db_get("main-branch", "trunk");
2353 }
2354 if( !zNewBranch || !zNewBranch[0]){
2355 zNewBranch = zBranchName;
2356 }
2357 @ <tr><th align="right" valign="top">Branching:</th>
2358 @ <td valign="top">
2359 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2360 @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
 
 
 
2361 @ Make this check-in the start of a new branch named:</label>
2362 @ <input id="brname" type="text" style="width:15;" name="brname"
2363 @ value="%h(zNewBranch)"
2364 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2365 if( !fHasHidden ){
 
 
 
 
 
 
 
 
 
 
2366 @ <tr><th align="right" valign="top">Branch Hiding:</th>
2367 @ <td valign="top">
2368 @ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag) />
2369 @ Hide branch
2370 @ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span>
2371 @ from the timeline starting from this check-in</label>
2372 @ </td></tr>
2373 }
 
 
2374 if( !fHasClosed ){
2375 if( is_a_leaf(rid) ){
2376 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2377 @ <td valign="top">
2378 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2379

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button