Skip to content

Commit 3e12699

Browse files
committed
Missing creation of .local/bin for shelluser update added
1 parent 87ba952 commit 3e12699

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

server/plugins-available/shelluser_base_plugin.inc.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,6 @@ function insert($event_name, $data) {
146146
$command .= ' -s ? -u ? ?';
147147
$app->system->exec_safe($command, $homedir, $data['new']['pgroup'], $data['new']['shell'], $uid, $data['new']['username']);
148148

149-
//* Create the .bashrc.d directory for ease of use and a more customisable bashrc environment
150-
if(!is_dir($homedir.'/.bashrc.d')){
151-
$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
152-
$app->system->chown($homedir.'/.bashrc.d', $data['new']['username']);
153-
$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
154-
}
155-
156-
//* Specified in FHS 3.0, https://refspecs.linuxfoundation.org/FHS_3.0/index.html
157-
//* Supported by Systemd/XDG, provides binaries via user ~/.local/bin directory and PATH
158-
if(!is_dir($homedir.'/.local/bin')){
159-
$app->file->mkdirs($homedir.'/.local/bin', '0750');
160-
$app->system->chown($homedir.'/.local', $data['new']['username'], false);
161-
$app->system->chgrp($homedir.'/.local', $data['new']['pgroup'], false);
162-
$app->system->chown($homedir.'/.local/bin', $data['new']['username'], false);
163-
$app->system->chgrp($homedir.'/.local/bin', $data['new']['pgroup'], false);
164-
}
165-
166149
$app->log("Executed command: ".$command, LOGLEVEL_DEBUG);
167150
$app->log("Added shelluser: ".$data['new']['username'], LOGLEVEL_DEBUG);
168151

@@ -203,13 +186,23 @@ function insert($event_name, $data) {
203186
$app->system->chown($homedir.'/.profile', $data['new']['username']);
204187
$app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']);
205188

206-
//* Create .bashrc.d directory
189+
//* Create the .bashrc.d directory for ease of use and a more customisable bashrc environment
207190
if(!is_dir($homedir.'/.bashrc.d')){
208191
$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
209192
$app->system->chown($homedir.'/.bashrc.d', $data['new']['username']);
210193
$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
211194
}
212195

196+
//* Specified in FHS 3.0, https://refspecs.linuxfoundation.org/FHS_3.0/index.html
197+
//* Supported by Systemd/XDG, provides binaries via user ~/.local/bin directory and PATH
198+
if(!is_dir($homedir.'/.local/bin')){
199+
$app->file->mkdirs($homedir.'/.local/bin', '0750');
200+
$app->system->chown($homedir.'/.local', $data['new']['username'], false);
201+
$app->system->chgrp($homedir.'/.local', $data['new']['pgroup'], false);
202+
$app->system->chown($homedir.'/.local/bin', $data['new']['username'], false);
203+
$app->system->chgrp($homedir.'/.local/bin', $data['new']['pgroup'], false);
204+
}
205+
213206
if($data['new']['chroot'] != 'jailkit') {
214207
$this->_add_user_bashrc();
215208
}
@@ -328,6 +321,7 @@ function update($event_name, $data) {
328321
$app->system->chgrp($homedir,$data['new']['pgroup']);
329322
}
330323
}
324+
331325
$app->system->usermod($data['old']['username'], 0, $app->system->getgid($data['new']['pgroup']), $homedir, $data['new']['shell'], $data['new']['password'], $data['new']['username']);
332326
$app->log("Updated shelluser: ".$data['old']['username'], LOGLEVEL_DEBUG);
333327

@@ -353,18 +347,28 @@ function update($event_name, $data) {
353347
fi
354348
355349
";
356-
$app->system->file_put_contents($homedir.'/.profile', $profile_content);
357-
$app->system->chown($homedir.'/.profile', $data['new']['puser']);
358-
$app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']);
350+
$app->system->file_put_contents($homedir.'/.profile', $profile_content);
351+
$app->system->chown($homedir.'/.profile', $data['new']['puser']);
352+
$app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']);
359353

360354

361-
//* Create .bashrc.d directory
355+
//* Create the .bashrc.d directory for ease of use and a more customisable bashrc environment
362356
if(!is_dir($homedir.'/.bashrc.d')){
363357
$app->file->mkdirs($homedir.'/.bashrc.d', '0750');
364-
$app->system->chown($homedir.'/.bashrc.d', $data['new']['puser']);
358+
$app->system->chown($homedir.'/.bashrc.d', $data['new']['username']);
365359
$app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']);
366360
}
367361

362+
//* Specified in FHS 3.0, https://refspecs.linuxfoundation.org/FHS_3.0/index.html
363+
//* Supported by Systemd/XDG, provides binaries via user ~/.local/bin directory and PATH
364+
if(!is_dir($homedir.'/.local/bin')){
365+
$app->file->mkdirs($homedir.'/.local/bin', '0750');
366+
$app->system->chown($homedir.'/.local', $data['new']['username'], false);
367+
$app->system->chgrp($homedir.'/.local', $data['new']['pgroup'], false);
368+
$app->system->chown($homedir.'/.local/bin', $data['new']['username'], false);
369+
$app->system->chgrp($homedir.'/.local/bin', $data['new']['pgroup'], false);
370+
}
371+
368372
if($data['new']['chroot'] != 'jailkit') {
369373
$this->_add_user_bashrc();
370374
}

0 commit comments

Comments
 (0)