midrange.com code scratchpad |
Name:
touchifs.rpgle
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
10/30/2017 09:37:31 pm
|
IP:
Logged
|
|
Description:
Proof of concept to show open() inherits the authorization list of the parent directory
|
Code:
- **free
-
- ctl-opt dftactgrp(*no) actgrp('QILE') bnddir('QC2LE');
-
- dcl-pr open int(10) extproc('open');
- filename pointer value options(*string);
- openflags int(10) value;
- mode uns(10) value options(*nopass);
- ccsid uns(10) value options(*nopass);
- txtcreatid uns(10) value options(*nopass);
- end-pr;
-
- dcl-pr close int(10) ExtProc('close');
- fd int(10) value;
- end-pr;
-
- dcl-pr errno int(10);
- end-pr;
-
- dcl-pr p_errno pointer extproc('__errno');
- end-pr;
-
- dcl-c O_RDONLY const(1);
- dcl-c O_WRONLY const(2);
- dcl-c O_RDWR const(4);
- dcl-c O_CREAT const(8);
- dcl-c O_EXCL const(16);
- dcl-c O_CCSID const(32);
- dcl-c O_TRUNC const(64);
- dcl-c O_APPEND const(256);
- dcl-c O_SYNC const(1024);
- dcl-c O_DSYNC const(2048);
- dcl-c O_RSYNC const(4096);
- dcl-c O_NOCTTY const(32768);
- dcl-c O_SHARE_RDONLY const(65536);
- dcl-c O_SHARE_WRONLY const(131072);
- dcl-c O_SHARE_RDWR const(262144);
- dcl-c O_SHARE_NONE const(524288);
- dcl-c O_CODEPAGE const(8388608);
- dcl-c O_TEXTDATA const(16777216);
- dcl-c O_TEXT_CREAT const(33554432);
- dcl-c O_INHERITMODE const(134217728);
- dcl-c O_LARGEFILE const(536870912);
-
- dcl-c S_IRUSR const(256);
- dcl-c S_IWUSR const(128);
- dcl-c S_IXUSR const(64);
- dcl-c S_IRWXU const(448);
- dcl-c S_IRGRP const(32);
- dcl-c S_IWGRP const(16);
- dcl-c S_IXGRP const(8);
- dcl-c S_IRWXG const(56);
- dcl-c S_IROTH const(4);
- dcl-c S_IWOTH const(2);
- dcl-c S_IXOTH const(1);
- dcl-c S_IRWXO const(7);
-
- dcl-s file varchar(64);
- dcl-s fd int(10) inz;
- dcl-s err int(10) inz;
-
- file = '/home/buck/newfile';
- fd = open(file:
- O_CREAT + O_CCSID + O_WRONLY + O_TRUNC + O_INHERITMODE:
- S_IRWXU:
- 1200);
- err = errno();
- dsply fd;
- dsply errno;
- dump(a);
- callp close(fd);
-
- *inlr = *on;
-
- dcl-proc errno;
- dcl-pi *n int(10);
- end-pi;
-
- dcl-s rtnval int(10) based(errno_p);
- dcl-s errno_p pointer;
-
- errno_p = p_errno;
- return rtnval;
-
- end-proc;
|
|
|