Plesk-Scheduled-Tasks reporting "No such file or directory" - plesk

I have a working Centos/Plesk (18.0.40 Update #1) environment running Plesk-Scheduled-Tasks with no problems, and I have a new machine that should be a duplicate of that machine (Plesk 18.0.42 Update #1) that is failing to run the Plesk-Scheduled-Tasks (reporting "No such file or directory" on all the tasks that I have added).
Eliminating as many permissions factors as possible, I am testing a scriptless task running "whoami" will work on the original machine but shows an "-: whoami: command not found" error message on the new.
Note, I am also declaring tasks at the domain level - if I was to add a top level task (where it prompts you for the System user) then it can use root and therefore works - but I do not want these tasks to run under root.
Clicking "Run Now" gives the following:

Hiho.
The run scheduled tasks and also the shell access if it´s enabled for your subscription is mostly chrooted. So you have only a minimum on commands which you can use here.
If you open your subscription via FTP Client you should see a bin folder in there. In the bin folder are all commands you are able to use in the chrooted shell.
Example on one of my subscriptions:
bash cat chmod cp curl du false grep groups gunzip gzip head id less ln ls
mkdir more mv pwd rm rmdir scp sh tail tar touch true unrar unzip vi wget

Related

cp: target '/path/to/directory' is not a directory

I really confused by target /path/to/directory is not a directory when i want to copying all files in build/* to the direction in by this rule in gitlab-ci.yml file:
script:
- cp -rf build/* /path/to/directory
I've also check this command by removing/adding / at end and start of the destination but won't help.
Note: it's OK when i manually run the cp command in server terminal and have no problem with it.This command was successful when i run it manually through terminal in ubuntu server.
So what's the problem here?
it's OK when i manually run the cp command in server terminal and have no problem with it.
That is probably because the target folder exists in the server itself, while it might not exist in the context of the GitLab runner.
You should either:
create the target folder:
mkdir -p /path/to/directory
or mount the server target folder as a data volume:
volumes = ["/path/to/bind/from/host:/path/to/bind/in/container:rw"]
I experienced a similar error because one of my files had a space in its name and so the path it was looking for was only reading the string after the space.

Default permission and ownership in WSL

I'm currently in the process of switching from an Ubuntu 18.04 VirtualBox to the WSL.
Everything is up and running to have a complete web dev environment.
Unfortunately, the file permission and ownership is kind of a problem for me right now.
--- Disclaimer---
I know that in a server environment this would be pretty bad and wouldn't be done.
This is just for my local development process and this requirement will stay there.
What I want to achieve is, to have a consistent set of permissions and ownerships within my /var/www (and all below).
Every element within /var/www should be owned by my shell user, regardless if file or dir.
Every element should have the group www-dataso that the webserver user have access.
Each file should have permission 0664 and each directory 0775.
every new element should follow these requirements.
What I researched so far:
If I make a new directory/ file from the shell or within VSCode, my user and group are used.
If I make a new directory from the windows explorer, the ownership is root:root. Nevertheless, I also have to figure out how to set default permissions for new objects.
I just want an easy to use way to CRUD my files from anywhere I am on my system.
Is there anyone with an idea for this?
Thanks a lot, Danaq.
Edit: It would also be ok, to set everything to www-data:ww-data and add my shell user to the www-data-group if the permissions are applied like explained above.
According to this, newer versions of the Remote-WSL server, when they get started will execute (if present):
~/.vscode-server/server-env-setup
~/.vscode-server-insiders/server-env-setup
(more on that)
So a solution is to execute:
# this will affect folders created from the editor
mkdir -p ~/.vscode-server/ && echo "umask 002" >> ~/.vscode-server/server-env-setup
mkdir -p ~/.vscode-server-insiders/ && echo "umask 002" >> ~/.vscode-server-insiders/server-env-setup
# this will affect folders created from terminals
echo "umask 002" >> ~/.bashrc
For everyone encountering the same issue and find this question:
Under ~[USER~/.profile I uncommented the umask-property and set it to 002.
This will, according to this guide, set all new created file to 0664 and all new directories to 0775.
I then added the www-data-user to the group of my shell-user with
sudo usermod -a -G www-data [GROUP].
So now, every file I'm creating is owned by and within the group of my shell user. But it can be red by the www-data-user too. This should lead to not always using the
find ./ -type d -exec chmod 775 {} \;
the command to set the right permissions on all directories of a web project after migration for example.
This solution does only help, if the files and directories are created from the WSL-bash. If you are using the explorer or trying to create a file from the VSCode-terminal, the default umask of 022 will be still applied.

Editing .desktop file to run executable as root?

I have compiled a c program into an executable that I would now like to integrate into the applications menu in Debian 7.4 XFCE. In order to run the application under normal circumstances, I am required to type
sudo myprogram
Now I have created my .desktop file and placed it in /usr/share/applications
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=myprogram
Comment=configuration loader
Exec=sudo loader
Icon=/usr/share/icons/hicolor/48x48/apps/myprogram.png
Terminal=false
Categories=Development;IDE
The item is added to my applications menu as expected, and the icon shows up properly. The problem, however, is that double clicking the menu item to launch the application does nothing.
If I navigate to /usr/bin (where I have placed my executable) and type "sudo myprogram", the program launches as expected.
What can I do to fix this issue and get the program to launch from the menu? Perhaps /usr/bin is not the correct place to put it, or I have the incorrect Exec command. I greatly appreciate the help.
I ended up using (after installing gksu)
Exec = gksu myprogram
this launches a graphical sudo prompt, which is sufficient for my needs.
This is what the setuid bit in the permissions is for. It makes executables run with permissions of the file owner. This only works on actual executables, not on shell scripts!
sudo chmod u+s myprogram
sudo chown root myprogram
./myprogram # now runs as root
Please be careful when using this as it will always execute that program as root no matter who executes it. You can limit access by setting it to your usergroup and deny all execute.
chgrp "${USER}" myprogram # provided you have individual groups set up
chmod a-x myprogram # deny all execute
This approach does not need additional installation of packages.
Terminal=true opens a new terminal window which runs
sudo -i to ask for the password.
Then, using sh to run the program, the Terminal is closed and myprogram runs in the background because it has a & at the end.
[Desktop Entry]
Type=Application
Name=...
Exec=sudo -i sh -c "myprogram &"
Terminal=true
Request: Please report if it works under your OS.
Tested under:
Xubuntu
The pkexec solution from askubuntu:
Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY APP_COMMAND
Try adding this to .desktop
Path=/path/to/myprogram

how to override the already existing workspaces in rtc using command scm or lscm

I have the requirement as i need to connect to the rtc and automatically checkout the files from the stream to the repository workspace.
I am writing the following commands in the bat file.
lscm login -r https://rtc.usaa.com/ccm -u uname -P password -n nickname -c
scm create workspace (workspacename) -r nickname -s (streamname)
lscm load workspace name -r nickname -d directorypath(c:codebase/rtc)
lscm logout -r nickname
while i am executing the above batch file for the first time it is creating the workspace and loading the project into the workspace path.
while i am executing the above batch file for the second time again it is creating the duplicate workspace with the same name and getting exception while loading.
I want to override the already existing workspace every time while loading but I didn't find a command for that.
can you please provide me any other way of doing it or any command that solves my problem
It will be good to delete existing local workspace sandbox before loading the new one. In my setup, we execute the following steps:
1. Delete local sandbox (if it makes sense delete existing repository workspace too)
2. Create new repository workspace
3. Load the new repository workspace to local sandbox
Either create a uniquely named workspace (perhaps by sticking a time stamp into the name?) and then delete it when you're done, or use the workspace's UUID from the creation step.
Instead of deleting and again writing the files into workspace, you can try accept incoming changes before load and then using "--force" attribute you can overwrite only the changes made files.
Accept using - SCM accept --flow-components -r <> -u <> -p <> --target
Use force at the end of the load command which you using.
this should work fine.

website and shell - how to set tmp dir permissions

I have some web service + some shell scripts which I want to execute with cron.
The problem is with the tmp directory.
To make webservice work I had to run command sudo chown -R www-data:www-data app/tmp (www-data is group and user used by apache)
The problem is that then when I execute CakeShell with some user I get lots of errors telling that some files in app/tmp dir are not writable - this is because tmp dir is owned by www-data...
I can run those scripts with root user - then I don't get any errors...
When I run scripts with root user, from time to time those scripts modify some files in app/tmp and then I got many errors on webservice (website) that some files in app/tmp are not writable. It seems that runing scripts sometimes modifies tmp files with permissions of user executing those scripts.
I want to execute those scripts from cron.
And my questions are:
What is correct setup for app/tmp dir (permissions, user, group etc) and how I can set it up to get both webservice and executing scripts from shell working?
Is it possible to set up permissions to app/tmp dir to allow writing and reading it for all users and groups? Is it good idea?
If you do not use a shared webserver, you can use a permissive ownership:
chmod -R 777 app/tmp
If you own the server/VPS, it's not a security hole, since the more sensible user (www-data) already have access.
OR
You can run the crontab "in name of" www-data user, using the command su

Resources