~ubuntu-branches/ubuntu/maverick/policycoreutils/maverick

« back to all changes in this revision

Viewing changes to run_init/run_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Manoj Srivastava
  • Date: 2005-03-17 19:54:20 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050317195420-ue1cxmipm7mm9ie7
Tags: 1.22+0-2
* New upstream release
* Bug fix: "policycoreutils: package description typo(s) and the like",
  thanks to Florian Zumbiehl                         (Closes: #300054).

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include <selinux/context.h>              /* for context-mangling functions */
50
50
#include <fcntl.h>
51
51
#include <ctype.h>
 
52
#include <limits.h>
 
53
#ifdef USE_NLS
52
54
#include <libintl.h>
53
55
#include <locale.h>
54
56
#define _(msgid) gettext (msgid)
 
57
#else
 
58
#define _(msgid) (msgid)
 
59
#endif
55
60
#ifndef PACKAGE
56
61
#define PACKAGE "policycoreutils"   /* the name of this package lang translation */
57
62
#endif
60
65
  where: <script> is the name of the init script to run,\n\
61
66
         <args ...> are the arguments to that script.")
62
67
 
63
 
#define CONTEXT_FILE "/etc/security/initrc_context"
 
68
#define CONTEXT_FILE "initrc_context"
64
69
#ifdef USE_PAM
65
70
 
66
71
/************************************************************************
269
274
  FILE* fp;
270
275
  char  buf[255], *bufp;
271
276
  int buf_len;
272
 
  
273
 
  fp = fopen(CONTEXT_FILE, "r");
 
277
  char context_file[PATH_MAX];
 
278
  snprintf(context_file, sizeof(context_file)-1, "%s/%s", selinux_contexts_path(), CONTEXT_FILE);
 
279
  fp = fopen(context_file, "r");
274
280
  if (!fp) {
275
 
    fprintf(stderr, _("Could not open file %s\n"), CONTEXT_FILE);
 
281
    fprintf(stderr, _("Could not open file %s\n"), context_file);
276
282
    return -1;
277
283
  }
278
284
 
299
305
  }
300
306
out:
301
307
  fclose(fp);
302
 
  fprintf(stderr, _("No context in file %s\n"), CONTEXT_FILE);
 
308
  fprintf(stderr, _("No context in file %s\n"), context_file);
303
309
  return -1;
304
310
 
305
311
} /* get_init_context() */
312
318
  extern char *optarg;               /* used by getopt() for arg strings */
313
319
  extern int opterr;                 /* controls getopt() error messages */
314
320
  security_context_t new_context;            /* context for the init script context  */
 
321
  
 
322
#ifdef USE_NLS
315
323
  setlocale(LC_ALL, "");
316
324
  bindtextdomain(PACKAGE, LOCALEDIR);
317
325
  textdomain(PACKAGE);
 
326
#endif
318
327
 
319
328
  /* Verify that we are running on a flask-enabled kernel. */
320
329
  if( !is_selinux_enabled() ) {
367
376
       fprintf(stderr, _("Could not set exec context to %s.\n"), new_context);
368
377
       exit(-1);
369
378
  }
370
 
  if ( execvp(argv[1], argv + 1) ) {
 
379
  /*
 
380
   * Do not execvp the command directly from run_init; since it would run
 
381
   * under with a pty under sysadm_devpts_t. Instead, we call open_init_tty,
 
382
   * which transitions us into initrc_t, which then spawns a new
 
383
   * process, that gets a pty with context initrc_devpts_t. Just
 
384
   * execvp or using a exec(1) recycles pty's, and does not open a new
 
385
   * one. 
 
386
   */
 
387
  if ( execvp("/usr/sbin/open_init_pty", argv) ) {
371
388
    perror("execvp");
372
389
    exit(-1);
373
390
  }