home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / hp / 14420 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  3.8 KB

  1. Path: sparky!uunet!psgrain!ee.und.ac.za!tplinfm
  2. From: barrett@daisy.ee.und.ac.za (Alan P Barrett)
  3. Newsgroups: comp.sys.hp
  4. Subject: Re: Has anyone ported "op" to HP-UX ...?
  5. Date: 30 Dec 1992 11:53:24 +0200
  6. Organization: Dept. Elec. Eng., Univ. Natal, Durban, S. Africa
  7. Lines: 117
  8. Message-ID: <1hrrikINNosj@daisy.ee.und.ac.za>
  9. References: <1hpqihINNlag@diamond.pgh.wec.com>
  10. NNTP-Posting-Host: daisy.ee.und.ac.za
  11.  
  12. Here are the diffs between the alpha version of op posted to the net some
  13. time ago, and my version which runs on HP-UX 7.0.  A later (non-alpha)
  14. version of op was recently posted to one of the sources groups, but I
  15. haven't integrated my changes into it.
  16.  
  17. --apb
  18. Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa
  19. RFC822: barrett@ee.und.ac.za                    Bang: m2xenix!undeed!barrett
  20.  
  21. diff -u3 +recursive orig/Makefile apb/Makefile
  22. --- orig/Makefile    Wed Dec 30 11:46:43 1992
  23. +++ apb/Makefile    Wed Dec 30 11:46:58 1992
  24. @@ -1,11 +1,12 @@
  25.  CFLAGS=-g -I.
  26.  
  27. -VPF = vfprintf.o
  28. +# VPF = vfprintf.o
  29.  REG = regexp.o regsub.o regerror.o
  30.  OBJ = lex.o main.o atov.o $(REG) $(VPF)
  31. +LIBS = -lBSD
  32.  
  33.  op: $(OBJ) $(REG)
  34. -    $(CC) $(CFLAGS) -o $@ $(OBJ) -ll
  35. +    $(CC) $(CFLAGS) -o $@ $(OBJ) -ll $(LIBS)
  36.  
  37.  clean:
  38.      rm -f $(OBJ) op core 
  39. diff -u3 +recursive orig/main.c apb/main.c
  40. --- orig/main.c    Wed Dec 30 11:46:45 1992
  41. +++ apb/main.c    Wed Dec 30 11:46:59 1992
  42. @@ -17,6 +17,16 @@
  43.  #include "defs.h"
  44.  #include "regexp.h"
  45.  
  46. +/* I don't know why they use both re_comp and regcomp.
  47. + * I am not even sure what re_comp and re_exec do.
  48. + * I assume that re_comp magicly keeps the compiled regexp for use
  49. + * by re_exec.
  50. + * --apb */
  51. +static regexp *re_reg = NULL;
  52. +#define re_comp(pat) ((re_reg ? (void)free(re_reg) : (void)0), \
  53. +              ((re_reg = regcomp(pat))==NULL))
  54. +#define re_exec(str) (regexec(re_reg,(str)))
  55. +
  56.  #ifndef LOG_AUTH
  57.  /*
  58.  **  Pmax's don't have LOG_AUTH
  59. @@ -373,20 +383,27 @@
  60.      char        *new_argv[MAXARG];
  61.      char        str[MAXSTRLEN], buf[4*MAXSTRLEN];
  62.  
  63. -    if ((cp = FindOpt(cmd, "uid")) == NULL) {
  64. -        if (setuid(0) < 0)
  65. -            fatal("Unable to set uid to default", cp);
  66. +    /* The order of some of these actions is important.
  67. +     *
  68. +     * chroot and setgroups don't work unless we are root, so they
  69. +     * must happen before setuid.
  70. +     * chdir should probably happen after setgroups and setuid so that
  71. +     * they will fail if the target user doesn't have permission to
  72. +     * do them.
  73. +     */
  74. +
  75. +    if ((cp = FindOpt(cmd, "chroot")) == NULL) {
  76. +        ;        /* don't have a default */
  77.      } else {
  78. -        if ((pw = getpwnam(cp)) == NULL) {
  79. -            if (setuid(atoi(cp)) < 0)
  80. -                fatal("Unable to set uid to %s", cp);
  81. -        }
  82. -        if (setuid(pw->pw_uid) < 0)
  83. -            fatal("Unable to set uid to %s", cp);
  84. +        if (chroot(cp) < 0)
  85. +            fatal("Unable to chroot to %s", cp);
  86.      }
  87.  
  88.      if ((cp = FindOpt(cmd, "gid")) == NULL) {
  89.          ;        /* don't have a default */
  90. +                /* XXX The default set of gids should
  91. +                 * probably be based on what would happen
  92. +                 * if the target user really logged in */
  93.      } else {
  94.          for (cp=GetField(cp, str); cp!=NULL; cp=GetField(cp, str)) {
  95.              if ((gr = getgrnam(cp)) != NULL)
  96. @@ -398,6 +415,18 @@
  97.              fatal("Set group failed");
  98.      }
  99.  
  100. +    if ((cp = FindOpt(cmd, "uid")) == NULL) {
  101. +        if (setuid(0) < 0)
  102. +            fatal("Unable to set uid to default", cp);
  103. +    } else {
  104. +        if ((pw = getpwnam(cp)) == NULL) {
  105. +            if (setuid(atoi(cp)) < 0)
  106. +                fatal("Unable to set uid to %s", cp);
  107. +        }
  108. +        if (setuid(pw->pw_uid) < 0)
  109. +            fatal("Unable to set uid to %s", cp);
  110. +    }
  111. +
  112.      if ((cp = FindOpt(cmd, "umask")) == NULL) {
  113.          if (umask(0022) < 0)
  114.              fatal("Unable to set umask to default");
  115. @@ -404,13 +433,6 @@
  116.      } else {
  117.          if (umask(atov(cp, 8)) < 0)
  118.              fatal("Unable to set umask to %s", cp);
  119. -    }
  120. -
  121. -    if ((cp = FindOpt(cmd, "chroot")) == NULL) {
  122. -        ;        /* don't have a default */
  123. -    } else {
  124. -        if (chroot(cp) < 0)
  125. -            fatal("Unable to chroot to %s", cp);
  126.      }
  127.  
  128.      if ((cp = FindOpt(cmd, "dir")) == NULL) {
  129.