develooper Front page | perl.vmsperl | Postings from January 2002

Privileges won't let me "opendir"?

Thread Next
From:
Tom Edelson
Date:
January 29, 2002 13:05
Subject:
Privileges won't let me "opendir"?
Message ID:
0632CC5F67853B4D96D542BAE8AD008266860F@merc08.na.sas.com
The following seems like a bug to me, but maybe I'm missing something ...

The built-in "opendir" function doesn't seem to follow normal VMS security rules.  In particular, if I have access to a directory, but only because I have privileges turned on, I think opendir should succeed, but it doesn't.  

  $ perl -v

  This is perl, v5.6.1 built for VMS_AXP
  [...]

With no access in the directory's security profile, and no privileges, naturally I can't read the directory through DCL and opendir doesn't work either:

  $ DIR /SEC TEMP.DIR

  Directory $1$DUA330:[HOSTVAX.TOEDEL.SCRATCH]

  TEMP.DIR;1           [SYSTEM]                         (RWE,RWE,RE,)
  Total of 1 file.

  $ SET PROCESS /PRIVILEGE=(NOALL,NETMBX,TMPMBX)

  $ DIR [.TEMP]
  %DIRECT-E-OPENIN, error opening $1$DUA330:[HOSTVAX.TOEDEL.SCRATCH.TEMP]*.*;* as input
  -RMS-E-PRV, insufficient privilege or file protection violation

  $ perl -e "print ""<"", opendir ($dh, ""[.temp]""), "">"" "
  <>

If I give myself BYPASS privilege, now I can read the directory through DCL, but opendir still doesn't work:

  $ SET PROCESS /PRIVILEGE=BYPASS

  $ DIR [.TEMP]

  Directory $1$DUA330:[HOSTVAX.TOEDEL.SCRATCH.TEMP]

  FOO.TXT;1           

  Total of 1 file.

  $ perl -e "print ""<"", opendir ($dh, ""[.temp]""), "">"" "
  <>

Now if I change the protection on the directory so that the world can read it, then opendir does work:

  $ SET SECURITY /PROTECTION=W:RE TEMP.DIR

  $ perl -e "print ""<"", opendir ($dh, ""[.temp]""), "">"" "
  <1>

This is not good news when you're writing an installation program, whose users generally have privileges, and may have some of the accesses that they need only through privileges.  

I suppose I could work around it by explicitly [and temporarily] giving myself access to the directory from within the program.  Anybody happen to know if there's a way to do this other than invoking DCL from Perl, e.g. with "system()"?  

Thanks.

/	Tom Edelson
	VMS Release Engineering
	SAS Institute, Inc.
	Tom.Edelson@sas.com


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About