[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

579.0. "Setting file protection" by TSG::KARDON () Mon Oct 12 1987 18:52

    Is there a run-time library routine or system service call to
    set the protection on an existing file or change the user's
    default protection on file creation.
    
    Thanks in advance,
    -Scott
T.RTitleUserPersonal
Name
DateLines
579.1chmod(2) and umask(2)TOOK::MICHAUDJeff MichaudMon Oct 12 1987 19:062
    chmod(2) and fchmod(2) to change the protection on an exsisting
    file.  Use umask(2) to control the protection assigned on creation.
579.2Must be called from BLISSTSG::KARDONMon Oct 12 1987 20:3711
    Thanks for the names of the C run-time routines.
    Unfortunately, I'm still programming in BLISS.  Could anyone
    tell me either:
    
    		a) The names of alternate routines, easily callable
    		   from BLISS.
    
    		b) How I call a C system function from BLISS.
    
    Thanks,
    -Scott
579.3JANUS::PALKATue Oct 13 1987 07:5315
    SYS$SETDFPROT allows you to read and/or write the default file
    protection for the process. (see the RMS manual for details). This is
    the equivalent of SET PROT/DEF. This is overridden by the protection of
    an existing file of the same name, or by a default protection in the
    directory. 
    
    You can change the protection of a file you have been writing to if you
    link an XABPRO to the FAB when you use $CLOSE. I dont think opening the
    file for write access and then closing it is sufficient. 

    You can probably also change the protection by direct QIOs (IO$_ACCESS
    followed by IO$_MODIFY?) to the ACP. 
    
    Andrew
    
579.4Try the toolshedROCK::TUMBLINTue Oct 13 1987 12:306
    I remember seeing a couple of routines in the toolshed to set the
    file protection, written by Peter Gilbert. You may want to check
    these routines.
    
    /Henry
     
579.5AKA::PARKWho you jiving with that cosmic debris?Fri Oct 16 1987 16:1335
    
    re: .2
    
    All of the Vax C run-time routines adhere to the VAX calling standard.
    Therefore, you only need to know what the parameters are and what
    mechanism they are passed by. 
    
    For chmod:
    
    	status.wlc.v = chmod( file_spec.rt.r , mode.rlu.v );
    
    	file_spec	- Address of a zero-terminated string containing
    			  the filename of the file to change protection.
    	mode		- Protection bits:  as follows:
    
    			xxxxxxxxxxxxxxxxxxxxxxxooooooooo
    			<-----don't care------>rwerwerwe
    						^  ^  ^
    						|  |  |
    					Owner---+  |  |
    					Group------+  |
    					World---------+
    
    	returns 0 if successful, -1 if failure
    
    For umask:
    
    	status.wlc.v = umask( mode_complement.rlu.v );
    
    	mode	- bitmask of bits to turn OFF when creating a new file.
    		  Same as in chmod.
    
        returns same values as chmod
    
    -x
579.6VIDEO::LEICHTERJJerry LeichterFri Oct 16 1987 22:434
While chmod will work, umask won't - it has no effect on the VMS-level default
protection - it sets a cell used by the C RTL when IT creates files.

							-- Jerry