Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ultrix 4.5 Configure bug #766

Closed
p5pRT opened this issue Oct 22, 1999 · 2 comments
Closed

Ultrix 4.5 Configure bug #766

p5pRT opened this issue Oct 22, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 22, 1999

Migrated from rt.perl.org#1690 (status was 'resolved')

Searchable as RT1690$

@p5pRT
Copy link
Author

p5pRT commented Oct 26, 1999

From @jhi

Could you please apply the following patch with

  patch -p1 < the.patch

and then retry

  rm config.sh
  ./Configure ...

diff -rc 5.005_03/Configure 5.005_03+getmnt/Configure
*** 5.005_03/Configure Tue Oct 26 12​:29​:24 1999
--- 5.005_03+getmnt/Configure Tue Oct 26 12​:31​:30 1999
***************
*** 335,340 ****
--- 335,341 ----
  d_fsetpos=''
  i_sysmount=''
  d_fstatfs=''
+ d_statfs=''
  d_statfsflags=''
  i_sysstatvfs=''
  d_fstatvfs=''
***************
*** 354,359 ****
--- 355,361 ----
  d_uname=''
  d_gethostprotos=''
  d_getlogin=''
+ d_getmntent=''
  d_getnbyaddr=''
  d_getnbyname=''
  d_getnent=''
***************
*** 7265,7278 ****
  set sys/mount.h i_sysmount
  eval $inhdr
 
  : see if fstatfs exists
  set fstatfs d_fstatfs
  eval $inlibc
 
  : see if statfs knows about mount flags
! echo " "
! set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
! eval $hasfield
 
  : see if this is a sysstatvfs.h system
  set sys/statvfs.h i_sysstatvfs
--- 7267,7290 ----
  set sys/mount.h i_sysmount
  eval $inhdr
 
+ : see if statfs exists
+ set statfs d_statfs
+ eval $inlibc
+
  : see if fstatfs exists
  set fstatfs d_fstatfs
  eval $inlibc
 
  : see if statfs knows about mount flags
! case "$d_statfs" in
! define) set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
! eval $hasfield
! ;;
! *) val="$undef"
! set d_statfsflags
! eval $setvar
! ;;
! esac
 
  : see if this is a sysstatvfs.h system
  set sys/statvfs.h i_sysstatvfs
***************
*** 7352,7357 ****
--- 7364,7373 ----
  set mntent.h i_mntent
  eval $inhdr
 
+ : see if getmnt exists
+ set getmnt d_getmnt
+ eval $inlibc
+
  : see if getmntent exists
  set getmntent d_getmntent
  eval $inlibc
***************
*** 11824,11829 ****
--- 11840,11846 ----
  d_fpathconf='$d_fpathconf'
  d_fsetpos='$d_fsetpos'
  d_fstatfs='$d_fstatfs'
+ d_statfs='$d_statfs'
  d_statfsflags='$d_statfsflags'
  d_fstatvfs='$d_fstatvfs'
  d_getmntent='$d_getmntent'
***************
*** 11837,11842 ****
--- 11854,11860 ----
  d_gethname='$d_gethname'
  d_gethostprotos='$d_gethostprotos'
  d_getlogin='$d_getlogin'
+ d_getmntent='$d_getmntent'
  d_getnbyaddr='$d_getnbyaddr'
  d_getnbyname='$d_getnbyname'
  d_getnent='$d_getnent'
diff -rc 5.005_03/config_h.SH 5.005_03+getmnt/config_h.SH
*** 5.005_03/config_h.SH Tue Oct 26 12​:32​:43 1999
--- 5.005_03+getmnt/config_h.SH Tue Oct 26 12​:47​:20 1999
***************
*** 275,280 ****
--- 275,286 ----
  */
  #$i_mntent I_MNTENT /**/
 
+ /* HAS_GETMNT​:
+ * This symbol, if defined, indicates that the getmnt routine is
+ * available to lookup mount entries by filename.
+ */
+ #$d_getmntent HAS_GETMNTENT /**/
+
  /* HAS_GETMNTENT​:
  * This symbol, if defined, indicates that the getmntent routine is
  * available to lookup mount entries in some data base or other.
diff -rc 5.005_03/perl.c 5.005_03+getmnt/perl.c
*** 5.005_03/perl.c Tue Oct 26 12​:30​:44 1999
--- 5.005_03+getmnt/perl.c Tue Oct 26 12​:42​:41 1999
***************
*** 65,71 ****
  static void open_script _((char *, bool, SV *, int *fd));
  static void usage _((char *));
  #ifdef IAMSUID
! static int fd_on_nosuid_fs _((int));
  #endif
  static void validate_suid _((char *, char*, int));
  static I32 read_e_script _((int idx, SV *buf_sv, int maxlen));
--- 65,71 ----
  static void open_script _((char *, bool, SV *, int *fd));
  static void usage _((char *));
  #ifdef IAMSUID
! static int file_on_nosuid_fs _((int, char *));
  #endif
  static void validate_suid _((char *, char*, int));
  static I32 read_e_script _((int idx, SV *buf_sv, int maxlen));
***************
*** 2082,2096 ****
 
  #ifdef IAMSUID
  static int
! fd_on_nosuid_fs(int fd)
  {
  int on_nosuid = 0;
  int check_okay = 0;
  /*
! * Preferred order​: fstatvfs(), fstatfs(), getmntent().
! * fstatvfs() is UNIX98.
! * fstatfs() is BSD.
! * getmntent() is O(number-of-mounted-filesystems) and can hang.
  */
 
  # ifdef HAS_FSTATVFS
--- 2082,2098 ----
 
  #ifdef IAMSUID
  static int
! file_on_nosuid_fs(int fd, char *path)
  {
  int on_nosuid = 0;
  int check_okay = 0;
  /*
! * Preferred order​: fstatvfs(), fstatfs(), getmnt(), getmntent().
! * fstatvfs() is UNIX98 and uses the fd.
! * fstatfs() is BSD 4.3+ and uses the fd.
! * getmnt() is BSD 4.2 (4.1?) and uses the path.
! * getmntent() is O(number-of-mounted-filesystems) and
! * uses neither fd nor path and can hang.
  */
 
  # ifdef HAS_FSTATVFS
***************
*** 2098,2119 ****
  check_okay = fstatvfs(fd, &stfs) == 0;
  on_nosuid = check_okay && (stfs.f_flag & ST_NOSUID);
  # else
! # if defined(HAS_FSTATFS) && defined(HAS_STRUCT_STATFS_FLAGS)
! struct statfs stfs;
  check_okay = fstatfs(fd, &stfs) == 0;
- # undef PERL_MOUNT_NOSUID
- # if !defined(PERL_MOUNT_NOSUID) && defined(MNT_NOSUID)
- # define PERL_MOUNT_NOSUID MNT_NOSUID
- # endif
- # if !defined(PERL_MOUNT_NOSUID) && defined(MS_NOSUID)
- # define PERL_MOUNT_NOSUID MS_NOSUID
- # endif
- # if !defined(PERL_MOUNT_NOSUID) && defined(M_NOSUID)
- # define PERL_MOUNT_NOSUID M_NOSUID
- # endif
- # ifdef PERL_MOUNT_NOSUID
  on_nosuid = check_okay && (stfs.f_flags & PERL_MOUNT_NOSUID);
! # endif
  # else
  # if defined(HAS_GETMNTENT) && defined(HAS_HASMNTOPT) && defined(MNTOPT_NOSUID)
  FILE *mtab = fopen("/etc/mtab", "r");
--- 2100,2127 ----
  check_okay = fstatvfs(fd, &stfs) == 0;
  on_nosuid = check_okay && (stfs.f_flag & ST_NOSUID);
  # else
! # undef PERL_MOUNT_NOSUID
! # if !defined(PERL_MOUNT_NOSUID) && defined(MNT_NOSUID)
! # define PERL_MOUNT_NOSUID MNT_NOSUID
! # endif
! # if !defined(PERL_MOUNT_NOSUID) && defined(MS_NOSUID)
! # define PERL_MOUNT_NOSUID MS_NOSUID
! # endif
! # if !defined(PERL_MOUNT_NOSUID) && defined(M_NOSUID)
! # define PERL_MOUNT_NOSUID M_NOSUID
! # endif
! # ifdef PERL_MOUNT_NOSUID
! # if defined(HAS_FSTATFS) && defined(HAS_STRUCT_STATFS_FLAGS)
! struct statfs stfs;
  check_okay = fstatfs(fd, &stfs) == 0;
  on_nosuid = check_okay && (stfs.f_flags & PERL_MOUNT_NOSUID);
! # else
! # ifdef HAS_GETMNT
! struct fs_data fsd;
! check_okay = getmnt(0, &fsd, 0, NOSTAT_ONE, path) == 1;
! on_nosuid = check_okay && (fsd.fd_req.flags & PERL_MOUNT_NOSUID);
! # endif /* getmnt */
! # endif /* fstatfs */
  # else
  # if defined(HAS_GETMNTENT) && defined(HAS_HASMNTOPT) && defined(MNTOPT_NOSUID)
  FILE *mtab = fopen("/etc/mtab", "r");
***************
*** 2121,2146 ****
  struct stat stb, fsb;
 
  if (mtab && (fstat(fd, &stb) == 0)) {
! while (entry = getmntent(mtab)) {
! if (stat(entry->mnt_dir, &fsb) == 0
! && fsb.st_dev == stb.st_dev)
  {
  /* found the filesystem */
  check_okay = 1;
  if (hasmntopt(entry, MNTOPT_NOSUID))
  on_nosuid = 1;
  break;
! } /* A single fs may well fail its stat(). */
  }
  }
  if (mtab)
  fclose(mtab);
! # endif /* mntent */
! # endif /* statfs */
! # endif /* statvfs */
  if (!check_okay)
! croak("Can't check filesystem of script \"%s\" for nosuid",
! PL_origfilename);
  return on_nosuid;
  }
  #endif /* IAMSUID */
--- 2129,2152 ----
  struct stat stb, fsb;
 
  if (mtab && (fstat(fd, &stb) == 0)) {
! while ((entry = getmntent(mtab))) {
! if (stat(entry->mnt_dir, &fsb) == 0 && fsb.st_dev == stb.st_dev)
  {
  /* found the filesystem */
  check_okay = 1;
  if (hasmntopt(entry, MNTOPT_NOSUID))
  on_nosuid = 1;
  break;
! } /* A single fs may well fail its stat(). Or hang :-( */
  }
  }
  if (mtab)
  fclose(mtab);
! # endif /* getmntent */
! # endif /* PERL_MOUNT_NOSUID​: fstatfs() or getmnt() */
! # endif /* fstatvfs */
  if (!check_okay)
! croak("Can't check filesystem of script \"%s\" for nosuid", PL_origfilename);
  return on_nosuid;
  }
  #endif /* IAMSUID */
***************
*** 2214,2220 ****
  if (PerlLIO_stat(SvPVX(GvSV(PL_curcop->cop_filegv)),&tmpstatbuf) < 0)
  croak("Permission denied"); /* testing full pathname here */
  #if defined(IAMSUID) && !defined(NO_NOSUID_CHECK)
! if (fd_on_nosuid_fs(PerlIO_fileno(PL_rsfp)))
  croak("Permission denied");
  #endif
  if (tmpstatbuf.st_dev != PL_statbuf.st_dev ||
--- 2220,2226 ----
  if (PerlLIO_stat(SvPVX(GvSV(PL_curcop->cop_filegv)),&tmpstatbuf) < 0)
  croak("Permission denied"); /* testing full pathname here */
  #if defined(IAMSUID) && !defined(NO_NOSUID_CHECK)
! if (file_on_nosuid_fs(PerlIO_fileno(PL_rsfp), scriptname))
  croak("Permission denied");
  #endif
  if (tmpstatbuf.st_dev != PL_statbuf.st_dev ||

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

@p5pRT
Copy link
Author

p5pRT commented Oct 26, 1999

From @jhi

Ho-hum, please ignore my first attempt at a patch. It needs more work.

--
$jhi++; # http​://www.iki.fi/jhi/
  # There is this special biologist word we use for 'stable'.
  # It is 'dead'. -- Jack Cohen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant