Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 90924 | Differences between
and this patch

Collapse All | Expand All

(-)dchroot.c.mid (-13 / +17 lines)
Lines 250-263 Link Here
250
			 */
250
			 */
251
251
252
			int i = 0;
252
			int i = 0;
253
      int shcmdstart = 0;
253
      int sh_cmd_start = 0;
254
			
254
			
255
#ifdef WITH_GNU_SU
255
#ifdef WITH_GNU_SU
256
      /* prevent gnu su from grabbing options inteded for the shell */
256
      /* prevent gnu su from grabbing options inteded for the shell */
257
			cmd[cmdnum++] = "--";
257
			cmd[cmdnum++] = "--";
258
#endif
258
#endif
259
259
260
      shcmdstart = cmdnum + 1;
260
      sh_cmd_start = cmdnum;
261
			while (argv[i] != NULL) {
261
			while (argv[i] != NULL) {
262
				cmd[cmdnum++] = argv[i];
262
				cmd[cmdnum++] = argv[i];
263
				i++;
263
				i++;
Lines 267-273 Link Here
267
267
268
			if (!opts.quiet) {
268
			if (!opts.quiet) {
269
				printf("(%s) ", chroot_to->name);
269
				printf("(%s) ", chroot_to->name);
270
				i = shcmdstart;
270
				i = sh_cmd_start;
271
				while (cmd[i]) {
271
				while (cmd[i]) {
272
					printf("%s ", cmd[i]);
272
					printf("%s ", cmd[i]);
273
					i++;
273
					i++;
Lines 345-355 Link Here
345
345
346
static void usage(char *cmd)
346
static void usage(char *cmd)
347
{
347
{
348
	printf("Usage: %s [OPTION...] [COMMAND]\n", cmd);
348
	printf("Usage:  %s [OPTION...] [[--] COMMAND]\n", cmd);
349
	printf
349
	printf("\n");
350
	    ("Execute COMMAND under a different root filesystem, " 
350
	printf("Execute COMMAND under a different root filesystem, "
351
	     "or if no command is given\n");
351
                                  "or if no command is given\n");
352
	printf("invoke a shell.\n");
352
	printf("invoke a shell.  Using -- causes all subsequent input "
353
                                  "to go to the shell\n");
354
  printf("in the chroot.\n");
353
	printf("\n");
355
	printf("\n");
354
	printf("  -a               Execute in all known chroots.\n");
356
	printf("  -a               Execute in all known chroots.\n");
355
	printf("  -c newroot       Execute in specified chroot.\n");
357
	printf("  -c newroot       Execute in specified chroot.\n");
Lines 359-365 Link Here
359
	printf("  -q               Be quiet.\n");
361
	printf("  -q               Be quiet.\n");
360
	printf("  -h               Print help message.\n");
362
	printf("  -h               Print help message.\n");
361
	printf("  -V               Print program version.\n");
363
	printf("  -V               Print program version.\n");
362
363
}
364
}
364
365
365
366
Lines 369-377 Link Here
369
	int rv = 0;
370
	int rv = 0;
370
	char **cmd;
371
	char **cmd;
371
	int index = 1;
372
	int index = 1;
373
  int opts_finished = 0;
372
	struct passwd *pwd;
374
	struct passwd *pwd;
373
375
374
	while (argv[index] && argv[index][0] == '-') {
376
	while (argv[index] && argv[index][0] == '-' && ! opts_finished) {
375
377
376
		if (argv[index][1] == '\0' || argv[index][2] != '\0') {
378
		if (argv[index][1] == '\0' || argv[index][2] != '\0') {
377
			dchroot_printf("Unknown option '-%c%c'.\n",
379
			dchroot_printf("Unknown option '-%c%c'.\n",
Lines 394-402 Link Here
394
			}
396
			}
395
			break;
397
			break;
396
		case 'l':
398
		case 'l':
397
			if ((chroots = read_chroots(CHROOTS_CONF)) == NULL) {
399
			if ((chroots = read_chroots(CHROOTS_CONF)) != NULL) {
398
				printf("No chroots found.\n");
399
			} else {
400
				list_chroots(chroots);
400
				list_chroots(chroots);
401
				printf("\n");
401
				printf("\n");
402
			}
402
			}
Lines 413-418 Link Here
413
			usage(argv[0]);
413
			usage(argv[0]);
414
			exit(EXIT_SUCCESS);
414
			exit(EXIT_SUCCESS);
415
			break;
415
			break;
416
    case '-':
417
      opts_finished = 1;
418
      break;
416
		default:
419
		default:
417
			dchroot_printf("Unknown option '%s'.\n",
420
			dchroot_printf("Unknown option '%s'.\n",
418
				       argv[index]);
421
				       argv[index]);
Lines 425-430 Link Here
425
			usage(argv[0]);
428
			usage(argv[0]);
426
			exit(EXIT_FAILURE);
429
			exit(EXIT_FAILURE);
427
		}
430
		}
431
428
		index++;
432
		index++;
429
	}
433
	}
430
434

Return to bug 90924