%%s 5/5/158 %%d D 1.2 30-Jul-83 08:29:28 tools 2 1 %%c Removed trailing periods from quoted strings. %%s 0/0/0 %%d D 1.1 27-Mar-82 14:58:28 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 %%D 2 #-h- chown.r 2976 asc 25-mar-82 09:26:03 v1.1 (sw-tools v1.1) #-h- main 1183 asc 25-mar-82 09:25:54 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- chown.r 2978 asc 30-jul-83 08:28:12 tools (lblh csam sventek) #-h- main 1180 asc 28-jul-83 23:02:21 tools (lblh csam sventek) %%E 2 ## ChOwn -- Make "user" the owner of one or more files. DRIVER(main) character filarg(FILENAMESIZE), usrnam(FILENAMESIZE) character uicstr(10) # "[ggg,mmm]" character dummy(FILENAMESIZE) filedes fd integer grp, i, junk, mem, arg integer c2i, chown, getarg, getwrd, index, decusr, open # function(s) call query( "usage: chown [ username | UIC ] file ...") if( getarg( 1, usrnam, FILENAMESIZE) == EOF ) %%D 2 call error( "? No UserName specified.") %%E 2 %%I 2 call error( "? No UserName specified") %%E 2 if( index( usrnam, '[') > 0 ) call strcpy( usrnam, uicstr) # UIC was specified. else if( decusr( usrnam, dummy, uicstr, dummy) == NO ) { call putlin( "? Can't find information on user named ``", ERROUT) call putlin( usrnam, ERROUT) %%D 2 call error( "''.") %%E 2 %%I 2 call error( "''") %%E 2 } i = 2 grp = c2i( uicstr, i, 8) # Group and member in octal. i = i + 1 mem = c2i( uicstr, i, 8) for( arg = 2 ; getarg( arg, filarg, FILENAMESIZE) != EOF ; arg = arg + 1 ) { fd = open( filarg, READ) if( fd == ERR ) call cant(filarg) else { call close(fd) if( chown( filarg, mem, grp) == ERR ) { call putlin("? Can't change owner of file ``", ERROUT) call putlin( filarg, ERROUT) %%D 2 call remark( "''.") %%E 2 %%I 2 call remark( "''") %%E 2 } } } DRETURN end #-h- decusr 874 asc 25-mar-82 09:25:55 v1.1 (sw-tools v1.1) ## DECUsr -- Get "home address", "UIC", and "owner" of given "name". integer function decusr( name, addres, uic, owner) character name(ARB), addres(ARB), uic(ARB), owner(ARB) character buf(MAXLINE), key(FILENAMESIZE) character usrfil(FILENAMESIZE), usrnam(FILENAMESIZE) filedes fd integer found, i integer equal, getlin, getwrd, open # function(s) call adrfil( usrfil) fd = open( usrfil, READ) if( fd == ERR ) call cant( usrfil) call strcpy( name, key) call fold( key) for( found = NO ; getlin( buf, fd) != EOF ; ) { i = 1 call fold( buf) junk = getwrd( buf, i, usrnam) junk = getwrd( buf, i, addres) junk = getwrd( buf, i, uic) junk = getwrd( buf, i, owner) if( equal( key, usrnam) == YES ) { found = YES break } } call close(fd) if( found == NO ) { addres(1) = EOS uic(1) = EOS owner(1) = EOS return(NO) } return(YES) end #-h- c2i 700 asc 25-mar-82 09:25:56 v1.1 (sw-tools v1.1) ## c2i - Convert str at in(i) to int (base b); increment i. integer function c2i(in, i, b) character in(ARB) integer index integer b, d, i, int, s string upstr "0123456789ABCDEF" string lostr "0123456789abcdef" if( 2 <= b & b <= 16 ) { while( in(i) == ' ' | in(i) == '@t' ) i = i + 1 s = 1 if( in(i) == '-' ) { s = -1 i = i + 1 } else if( in(i) == '+' ) { s = 1 i = i + 1 } for( int = 0 ; in(i) != EOS ; i = i + 1 ) { d = index(upstr, in(i)) if( d == 0 ) # Try lowercase. d = index(lostr, in(i)) if( d == 0 ) # Non-digit break int = b * int + d - 1 } return( int * s ) # Multiply by sign. } else return(0) end #-h- chown.fmt 465 asc 25-mar-82 09:26:04 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Chown (1) 27-Oct-81 change the ownership of file(s). .sy chown user file ... .ds chown makes "user" the owner of all listed files. "User" may be specified either as a username or a UIC ([ggg,mmm]). .fl The mail system database "~msg/address" is used to resolve usernames into UICs. .sa The UNIX command "chown". .di A message is displayed if you don't have the necessary privilege to change a file's owner. .au Dave Martin (Hughes Aircraft) .bu %%E 1