redmine

ifdefs polishing: GETMNTENT_SUPPORT & UNSHARE_SUPPORT

@@ -387,9 +387,11 @@ struct ctx { @@ -387,9 +387,11 @@ struct ctx {
387 int permitted_hookfiles; 387 int permitted_hookfiles;
388 #endif 388 #endif
389 389
390 -#ifdef GETMNTENT_SUPPORT 390 +#ifdef UNSHARE_SUPPORT
  391 +# ifdef GETMNTENT_SUPPORT
391 char *mountpoint[MAXMOUNTPOINTS+1]; 392 char *mountpoint[MAXMOUNTPOINTS+1];
392 int mountpoints; 393 int mountpoints;
  394 +# endif
393 #endif 395 #endif
394 396
395 synchandler_args_t synchandler_args[SHARGS_MAX]; 397 synchandler_args_t synchandler_args[SHARGS_MAX];
@@ -106,8 +106,10 @@ static const struct option long_options[] = @@ -106,8 +106,10 @@ static const struct option long_options[] =
106 {"permit-mprotect", optional_argument, NULL, PERMIT_MPROTECT}, 106 {"permit-mprotect", optional_argument, NULL, PERMIT_MPROTECT},
107 {"shm-mprotect", optional_argument, NULL, SHM_MPROTECT}, 107 {"shm-mprotect", optional_argument, NULL, SHM_MPROTECT},
108 #endif 108 #endif
109 -#ifdef GETMNTENT_SUPPORT 109 +#ifdef UNSHARE_SUPPORT
  110 +# ifdef GETMNTENT_SUPPORT
110 {"mountpoints", required_argument, NULL, MOUNTPOINTS}, 111 {"mountpoints", required_argument, NULL, MOUNTPOINTS},
  112 +# endif
111 #endif 113 #endif
112 #ifdef CAPABILITIES_SUPPORT 114 #ifdef CAPABILITIES_SUPPORT
113 {"preserve-capabilities",required_argument, NULL, CAP_PRESERVE}, 115 {"preserve-capabilities",required_argument, NULL, CAP_PRESERVE},
@@ -1241,7 +1243,8 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour @@ -1241,7 +1243,8 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour
1241 break; 1243 break;
1242 } 1244 }
1243 #endif 1245 #endif
1244 -#ifdef GETMNTENT_SUPPORT 1246 +#ifdef UNSHARE_SUPPORT
  1247 +# ifdef GETMNTENT_SUPPORT
1245 case MOUNTPOINTS: { 1248 case MOUNTPOINTS: {
1246 char *ptr; 1249 char *ptr;
1247 if (paramsource == PS_CONTROL) { 1250 if (paramsource == PS_CONTROL) {
@@ -1287,6 +1290,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour @@ -1287,6 +1290,7 @@ static int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsour
1287 } 1290 }
1288 break; 1291 break;
1289 } 1292 }
  1293 +# endif
1290 #endif 1294 #endif
1291 case PIDFILE: 1295 case PIDFILE:
1292 if (paramsource == PS_CONTROL) { 1296 if (paramsource == PS_CONTROL) {
@@ -1879,8 +1883,12 @@ int ctx_check(ctx_t *ctx_p) { @@ -1879,8 +1883,12 @@ int ctx_check(ctx_t *ctx_p) {
1879 error("\"--pivot-root\" cannot be used without \"--chroot\""); 1883 error("\"--pivot-root\" cannot be used without \"--chroot\"");
1880 } 1884 }
1881 1885
  1886 +# ifdef UNSHARE_SUPPORT
  1887 +# ifdef GETMNTENT_SUPPORT
1882 if ((ctx_p->flags[PIVOT_ROOT] != PW_OFF) && (ctx_p->mountpoints)) 1888 if ((ctx_p->flags[PIVOT_ROOT] != PW_OFF) && (ctx_p->mountpoints))
1883 warning("\"--mountpoints\" is set while \"--pivot-root\" is set, too"); 1889 warning("\"--mountpoints\" is set while \"--pivot-root\" is set, too");
  1890 +# endif
  1891 +# endif
1884 #endif 1892 #endif
1885 1893
1886 #ifdef VERYPARANOID 1894 #ifdef VERYPARANOID
@@ -2670,7 +2678,8 @@ int main(int _argc, char *_argv[]) { @@ -2670,7 +2678,8 @@ int main(int _argc, char *_argv[]) {
2670 ctx_p->state = STATE_STARTING; 2678 ctx_p->state = STATE_STARTING;
2671 2679
2672 { 2680 {
2673 -#ifdef GETMNTENT_SUPPORT 2681 +#ifdef UNSHARE_SUPPORT
  2682 +# ifdef GETMNTENT_SUPPORT
2674 struct mntent *ent; 2683 struct mntent *ent;
2675 FILE *ent_f; 2684 FILE *ent_f;
2676 2685
@@ -2683,10 +2692,9 @@ int main(int _argc, char *_argv[]) { @@ -2683,10 +2692,9 @@ int main(int _argc, char *_argv[]) {
2683 ret = errno; 2692 ret = errno;
2684 } 2693 }
2685 } 2694 }
2686 -#endif 2695 +# endif
2687 2696
2688 -#ifdef UNSHARE_SUPPORT 2697 +# define unshare_wrapper(a) \
2689 -#define unshare_wrapper(a) \  
2690 if (unshare(a)) {\ 2698 if (unshare(a)) {\
2691 error("Got error from unshare("TOSTR(a)")");\ 2699 error("Got error from unshare("TOSTR(a)")");\
2692 ret = errno;\ 2700 ret = errno;\
@@ -2707,7 +2715,7 @@ int main(int _argc, char *_argv[]) { @@ -2707,7 +2715,7 @@ int main(int _argc, char *_argv[]) {
2707 } 2715 }
2708 if (ctx_p->flags[DETACH_NETWORK] == DN_EVERYWHERE) 2716 if (ctx_p->flags[DETACH_NETWORK] == DN_EVERYWHERE)
2709 unshare_wrapper(CLONE_NEWNET); 2717 unshare_wrapper(CLONE_NEWNET);
2710 -#undef unshare_wrapper 2718 +# undef unshare_wrapper
2711 #endif 2719 #endif
2712 2720
2713 if (ctx_p->chroot_dir != NULL) { 2721 if (ctx_p->chroot_dir != NULL) {