-
Notifications
You must be signed in to change notification settings - Fork 19
/
QSHSETPROC.CLP
190 lines (151 loc) · 8.06 KB
/
QSHSETPROC.CLP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
PGM PARM(&USER &CRTPROFILE &CRTBASHPRF +
&CRTBASHRC &REPLACE)
DCL VAR(&REPLACE) TYPE(*CHAR) LEN(4)
DCL VAR(&CRTPROFILE) TYPE(*CHAR) LEN(4)
DCL VAR(&CRTBASHPRF) TYPE(*CHAR) LEN(4)
DCL VAR(&CRTBASHRC) TYPE(*CHAR) LEN(4)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
DCL VAR(&RTNUSERID) TYPE(*CHAR) LEN(10)
DCL VAR(&USERLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&HOMEDIR) TYPE(*CHAR) LEN(255)
DCL VAR(&PROFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&BASHRC) TYPE(*CHAR) LEN(255)
DCL VAR(&BASHPROF) TYPE(*CHAR) LEN(255)
DCL VAR(&PASSWORD) TYPE(*CHAR) LEN(10)
DCL VAR(&FOUND) TYPE(*CHAR) LEN(4)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/* At least 1 option must be *YES */
IF COND(&CRTPROFILE *NE *YES *AND &CRTBASHPRF +
*NE *YES *AND &CRTBASHRC *NE *YES) THEN(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('At +
least one copy option must be set to +
*YES. Profile copy cancelled') +
MSGTYPE(*ESCAPE)
ENDDO
/* Does selected user profile exist ? */
RTVUSRPRF USRPRF(&USER) RTNUSRPRF(&RTNUSERID)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('User +
profile' |> &USER |> 'may not exist or +
you cannot access it. Profile copy +
cancelled') MSGTYPE(*ESCAPE)
ENDDO
/* Set user info for user home dir */
/* Currently: /home/USERID assumed for home dir path */
CHGVAR VAR(&USERLIB) VALUE(&USER)
CHGVAR VAR(&HOMEDIR) VALUE('/home/' |< &USER)
CHGVAR VAR(&PROFILE) VALUE(&HOMEDIR |< '/.profile')
CHGVAR VAR(&BASHRC) VALUE(&HOMEDIR |< '/.bashrc')
CHGVAR VAR(&BASHPROF) VALUE(&HOMEDIR |< +
'/.bash_profile')
/* Create home dir for new user if not found */
MKDIR DIR(&HOMEDIR) DTAAUT(*RWX) OBJAUT(*ALL)
MONMSG MSGID(CPF0000)
/* TODO - disable home dir auth change for now. Needs more testing */
/* CHGOWN OBJ(&HOMEDIR) NEWOWN(&USER) RVKOLDAUT(*YES) +
SUBTREE(*NONE) */
/* CHGAUT OBJ(&HOMEDIR) USER(&USER) DTAAUT(*RWX) +
OBJAUT(*ALL) */
/* CHGAUT OBJ(&HOMEDIR) USER(*PUBLIC) DTAAUT(*RX) +
OBJAUT(*ALL) */
/*-------------------------------------------------------------*/
/* Are we creating .profile ? */
IF COND(&CRTPROFILE *EQ *YES) THEN(DO)
/* IF .profile exists and replace <> *YES, bail out */
QSHIFSCHK FILNAM(&PROFILE)
MONMSG MSGID(CPF9898) EXEC(DO)
ENDDO
MONMSG MSGID(CPF9897) EXEC(DO)
IF COND(&REPLACE *EQ *NO) THEN(SNDPGMMSG +
MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA(&PROFILE |> 'file already exists +
and replace is *NO. Profile copy +
cancelled') MSGTYPE(*ESCAPE))
ENDDO
/* Copy QShell .profile and set auth */
/* Copy with line feeds and code page 819 */
CPYTOSTMF +
FROMMBR('/QSYS.LIB/QSHONI.LIB/SOURCE.FILE/Q+
SHPROFILE.MBR') TOSTMF(&PROFILE) +
STMFOPT(*REPLACE) CVTDTA(*AUTO) +
ENDLINFMT(*LF) AUT(*INDIR) STMFCODPAG(819)
CHGOWN OBJ(&PROFILE) NEWOWN(&USER) RVKOLDAUT(*YES) +
SUBTREE(*NONE)
CHGAUT OBJ(&PROFILE) USER(&USER) DTAAUT(*RWX) +
OBJAUT(*ALL) SUBTREE(*NONE)
CHGAUT OBJ(&PROFILE) USER(*PUBLIC) DTAAUT(*RX) +
OBJAUT(*ALL) SUBTREE(*NONE)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&PROFILE +
|> 'file was copied/created') MSGTYPE(*DIAG)
ENDDO /* Creating .profile ? */
/*-------------------------------------------------------------*/
/* Are we creating .bash_profile ? */
IF COND(&CRTBASHPRF *EQ *YES) THEN(DO)
/* IF .bash_profile exists and replace <> *YES, bail out */
QSHIFSCHK FILNAM(&BASHPROF)
MONMSG MSGID(CPF9898) EXEC(DO)
ENDDO
MONMSG MSGID(CPF9897) EXEC(DO)
IF COND(&REPLACE *EQ *NO) THEN(SNDPGMMSG +
MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA(&BASHPROF|> 'file already exists +
and replace is *NO. Profile copy +
cancelled') MSGTYPE(*ESCAPE))
ENDDO
/* Copy .bash_profile and set auth */
/* Copy with line feeds and code page 819 */
CPYTOSTMF +
FROMMBR('/QSYS.LIB/QSHONI.LIB/SOURCE.FILE/Q+
SHBASHPRF.MBR') TOSTMF(&BASHPROF) +
STMFOPT(*REPLACE) CVTDTA(*AUTO) +
ENDLINFMT(*LF) AUT(*INDIR) STMFCODPAG(819)
CHGOWN OBJ(&BASHPROF) NEWOWN(&USER) RVKOLDAUT(*YES) +
SUBTREE(*NONE)
CHGAUT OBJ(&BASHPROF) USER(&USER) DTAAUT(*RWX) +
OBJAUT(*NONE)
CHGAUT OBJ(&BASHPROF) USER(*PUBLIC) DTAAUT(*RX) +
OBJAUT(*NONE)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&BASHPROF +
|> 'file was copied/created') MSGTYPE(*DIAG)
ENDDO /* Creating .bash_profile ? */
/*-------------------------------------------------------------*/
/* Are we creating .bashrc ? */
IF COND(&CRTBASHRC *EQ *YES) THEN(DO)
/* IF .bashrc exists and replace <> *YES, bail out */
QSHIFSCHK FILNAM(&BASHRC)
MONMSG MSGID(CPF9898) EXEC(DO)
ENDDO
MONMSG MSGID(CPF9897) EXEC(DO)
IF COND(&REPLACE *EQ *NO) THEN(SNDPGMMSG +
MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA(&BASHRC |> 'file already exists +
and replace is *NO. Profile copy +
cancelled') MSGTYPE(*ESCAPE))
ENDDO
/* Copy .bashrc and set auth */
/* Copy with line feeds and code page 819 */
CPYTOSTMF +
FROMMBR('/QSYS.LIB/QSHONI.LIB/SOURCE.FILE/Q+
SHBASHRC.MBR') TOSTMF(&BASHRC) +
STMFOPT(*REPLACE) CVTDTA(*AUTO) +
ENDLINFMT(*LF) AUT(*INDIR) STMFCODPAG(819)
CHGOWN OBJ(&BASHRC) NEWOWN(&USER) RVKOLDAUT(*YES) +
SUBTREE(*NONE)
CHGAUT OBJ(&BASHRC) USER(&USER) DTAAUT(*RWX) +
OBJAUT(*NONE)
CHGAUT OBJ(&BASHRC) USER(*PUBLIC) DTAAUT(*RX) +
OBJAUT(*NONE)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&BASHRC +
|> 'file was copied/created') MSGTYPE(*DIAG)
ENDDO /* Creating .bashrc ? */
/*-------------------------------------------------------------*/
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('QShell/PASE profile files were +
created successfully for user' |> &USER) +
MSGTYPE(*COMP)
RETURN
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Errors +
occurred while creating QShell/PASE profile +
files for user.' |> &USER |> 'Check +
joblog') MSGTYPE(*ESCAPE)