UNIX Free Pascal



         

. - 3


begin

readln(tx,ts);

d:=pos(':',ts);

nam1:=copy(ts,1,d-1);

delete(ts,1,d+2);

d:=pos(':',ts);

namb1:=copy(ts,1,d-1);

delete(ts,1,d);

val(namb1,d);

uid:=d;

d:=pos(':',ts);

namb2:=copy(ts,1,d-1);

val(namb2,d);

gid:=d;

if nam1=name then

f:=true;

end;

if not f then

begin

uid:=-1;

gid:=-1;

end;

close(tx);

end;

var

username,groupname,fname:string;

uid,gid:integer;

posit,temp:integer;

begin

if paramcount<>2 then

begin

writeln(': ',paramstr(0),' [:] ');

exit;

end;

username:=paramstr(1);

fname:=paramstr(2);

posit:=0;

posit:=pos(':',username);

if posit<>0 then

begin

groupname:=copy(username,posit+1,length(username)-posit);

username[0]:=char(posit-1);

getall('/etc/passwd',username,uid,gid);

getall('/etc/group',groupname,gid,temp);

end

else

getall('/etc/passwd',username,uid,gid);

if (uid=-1) or (gid=-1) then

begin

writeln(' ()');

exit;

end;

if not chown(fname,uid,gid) then

perror(' chown');

end.

13.47. chmodr, . .

uses linux,strings,sysutils,crt;

function gettype(mode:integer):char;

begin

if S_ISREG(mode) then

gettype:='-'

else

if S_ISDIR(mode) then

gettype:='d'

else

if S_ISCHR(mode) then

gettype:='c'

else

if S_ISBLK(mode) then

gettype:='b'

else

if S_ISFIFO(mode) then

gettype:='p'

else

gettype:='l';

end;

function obhod(prava:integer;name:pchar):boolean;

var

flag:boolean;

d:PDIR;

el:pdirent;