- Timestamp:
- Feb 17, 2019, 2:27:24 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/sh_dbIO.h
r481 r543 59 59 int sh_dbIO_list_filter (const char * c); 60 60 61 /* alternative rootfs */ 62 63 int sh_dbIO_init_rootfs (const char * rootfs); 64 size_t sh_dbIO_get_rootfs_len(); 65 char * sh_dbIO_rootfs_prepend(char * path); 66 char * sh_dbIO_rootfs_strip(char * path); 67 char * sh_dbIO_rootfs_strip_link(char * path); 68 61 69 #endif -
trunk/src/sh_dbIO.c
r541 r543 385 385 path[len-2] = '\0'; 386 386 } 387 return path; 388 } 389 390 /****************************************************************** 391 * 392 * Use different init rootfs (patch by Kemal H.) 393 * 394 ******************************************************************/ 395 396 static char * sh_dbIO_rootfs = NULL; 397 static size_t sh_dbIO_rootfs_len = 0; 398 399 int sh_dbIO_init_rootfs (const char * rootfs) 400 { 401 if (NULL == sh_dbIO_rootfs) 402 { 403 sh_dbIO_rootfs = sh_util_strdup (rootfs); 404 sh_dbIO_rootfs_len = sl_strlen(sh_dbIO_rootfs); 405 return 0; 406 } 407 return -1; 408 } 409 410 size_t sh_dbIO_get_rootfs_len() 411 { 412 return sh_dbIO_rootfs_len; 413 } 414 415 /* Prepend rootfs when reading from config file ('path' must be allocated with sufficient space). 416 */ 417 char * sh_dbIO_rootfs_prepend(char * path) 418 { 419 if (0 == sh_dbIO_rootfs_len) 420 return path; 421 422 memmove (path + sh_dbIO_rootfs_len, path, sl_strlen(path) + 1); 423 memcpy (path, sh_dbIO_rootfs, sh_dbIO_rootfs_len); 424 425 return path; 426 } 427 428 429 /* Strip rootfs when writing to database file. 430 */ 431 char * sh_dbIO_rootfs_strip(char * path) 432 { 433 if (sh_dbIO_rootfs_len == 0) 434 { 435 return path; 436 } 437 else 438 { 439 size_t len = sl_strlen(path); 440 441 memmove (path, path + sh_dbIO_rootfs_len, len + 1 - sh_dbIO_rootfs_len); 442 if(path[0] != '/') 443 { 444 path[0]='/'; 445 path[1]='\0'; 446 } 447 } 448 449 return path; 450 } 451 452 char * sh_dbIO_rootfs_strip_link(char * path) 453 { 454 if (sh_dbIO_rootfs_len == 0) 455 return path; 456 if (strstr(path, sh_dbIO_rootfs) == path) 457 { 458 size_t len = sl_strlen(path); 459 460 memmove (path, path + sh_dbIO_rootfs_len, len + 1 - sh_dbIO_rootfs_len); 461 } 387 462 return path; 388 463 } -
trunk/src/sh_files.c
r539 r543 215 215 { 216 216 char * p; 217 217 218 218 if (!str_s || *str_s == '\0') 219 219 return NULL; 220 220 221 221 *len = sl_strlen(str_s); 222 222 if (sh.flag.checkSum == SH_CHECK_INIT) 223 { 224 size_t addspace = sh_dbIO_get_rootfs_len(); 225 if (addspace != 0 && S_TRUE == sl_ok_adds (*len, addspace)) 226 *len += addspace; 227 } 228 223 229 if ( (str_s[0] == '"' && str_s[*len-1] == '"' ) || 224 230 (str_s[0] == '\'' && str_s[*len-1] == '\'') ) … … 1421 1427 SL_RETURN((-1), _("sh_files_pushfile")); 1422 1428 1429 if (sh.flag.checkSum == SH_CHECK_INIT) 1430 p = sh_dbIO_rootfs_prepend(p); 1431 1423 1432 if (len >= PATH_MAX) 1424 1433 { … … 1855 1864 } 1856 1865 1866 if (sh.flag.checkSum == SH_CHECK_INIT) 1867 tail = sh_dbIO_rootfs_prepend(tail); 1868 1857 1869 len = sl_strlen(tail); 1858 1870 … … 2763 2775 MODI_SET(theFile->check_flags, MODI_NOCHECK); 2764 2776 sh_tiger_get_mask_hashtype(&(theFile->check_flags)); 2777 2778 sh_dbIO_rootfs_strip(theFile->fullpath); 2779 if (theFile->link_path) 2780 sh_dbIO_rootfs_strip_link(theFile->link_path); 2765 2781 sh_dbIO_data_write (theFile, fileHash); 2766 2782 } -
trunk/src/sh_getopt.c
r539 r543 291 291 HAS_ARG_YES, 292 292 sh_dbCreate}, 293 { N_("init-rootfs"), 294 '-', 295 N_("Build database based on another rootfs"), 296 HAS_ARG_YES, 297 sh_dbIO_init_rootfs}, 293 298 { N_("wait-on-check"), 294 299 'w', -
trunk/src/sh_suidchk.c
r517 r543 1303 1303 /* Running init. Report on files detected. 1304 1304 */ 1305 sh_dbIO_rootfs_strip(theFile->fullpath); 1305 1306 sh_dbIO_data_write (theFile, fileHash); /* no call to sh_error_handle */ 1306 1307 SH_MUTEX_LOCK(mutex_thread_nolog);
Note:
See TracChangeset
for help on using the changeset viewer.