I have a problem when i want to install perl module
I make " cpan" to install cpan , but i get this "
Terminal does not support AddHistory.
Your configuration suggests that CPAN.pm should use a working
directory of
/home/cyrine/.cpan
Unfortunately we could not create the lock file
/home/cyrine/.cpan/.lock
due to permission problems.
Please make sure that the configuration variable
$CPAN::Config->{cpan_home}
points to a directory where you can write a .lock file. You can set
this variable in either a CPAN/MyConfig.pm or a CPAN/Config.pm in your
#INC path;
You don't seem to have a user configuration (MyConfig.pm) yet.
i make "y"
then i got this strange message :
mkdir /home/cyrine/.cpan/CPAN: Permission denied at /usr/share/perl/5.10/CPAN/Shell.pm >line 656
Any idea please?
Thank you
The immediate cause of this problem is that you don't have write permissions on /home/cyrine/.cpan. In my experience, this is most often the result of logging in as a normal user, then running cpan for the first time on that account in a su session, causing the CPAN configuration to be created in ~cyrine (because you have cyrine's environment), but owned by root (because su has given you root's permissions). Assuming that is the case, you should be able to resolve this my suing to root, running the command chown -R cyrine.cyrine /home/cyrine/.cpan and then running cpan as user cyrine.
Related
when I run command./config.sh --- while trying to setup GitHub runner on server I get this error
An error occurred: Permission to read the directory contents is required for '/var/www/usr/data/actions-runner' and each directory up the hierarchy. Access to the path '/var/www' is denied.
folder /var/www/ is owned by root, and usr running /.configure command has proper rights on /usr/data/action-runner
I tried running above command after adding "usr" to sudo then it tells me command must not run as sudo. So there is no winning here. I personally do not want to run command as sudo so I didn't try to figure out this error.
But, burning question I have is why does this configure script cares if it has read permission on /var/www/
This kind of does not addup
You can run sudo chmod 0755 /var/www, which fixed the problem for me
I want to write a .sh-script that sends a message to my ejabberd-account. (the script is "called" by the apache2 standard-user "www-data").
The script should execute the following command: ejabberdctl send_message chat admin#my-domain user#my-domain "title" "my message"
However, I can't run any ejabberdctl command without "being" root. So sudo ejabberdctl is not working (in terminal or any .sh-script). I can only do sudo -s followed by ejabberdctl my-command, which doesn't work in .sh-scripts (or am I wrong?).
(I've installed ejabberd 20.07 on ubuntu 20.04 with the help of this tutorial: Install Ejabberd...)
Is there a way to run a command in a .sh-script as "real root" or to create a root-session and run the command there (like I do manually with sudo -s ...)?
Is there any solution to my problem or should I install ejabberd the "normal way"?
When ejabberd is compiled and installed from source code, it's possible to prepare it with something like
./configure -–enable-group=ejagroup
Then, you can simply create the system group ejagroup, and add the www-data user to that ejagroup.
See https://docs.ejabberd.im/admin/installation/#options
In your case, that you use the Debian package from ProcessOne, I see the tutorial mentions that you create a system account called ejabberd. Maybe you can run ejabberdctl from that account, no need to be root?
I still don't know why I can only run ejabberdctl when I'm "logged-in" as root (sudo ejabberdctl is still not working)
Is my .bashrc file wrong? (last line: PATH=$PATH:/opt/ejabberd-20.07/bin/)
Anyway, at least I can run sudo /opt/ejabberd-20.07/bin/ejabberdctl my_command with any user, like they did here: Ejabberd sbin/ejabberdctl start (No such file or directory)
Has someone else experienced this weird behavior with sudo: any_command: not found ?
Let me know if you have a more "elegant" solution to my problem.
I get the error when trying to run a script. The script previously worked, but I edited one part of the code in Notepad++ (I change a ">" to a "<" ).
Any help would be appreciated! I was wondering whether it was a formatting issue after editing and saving in Notepad++ or if somehow my edit breaks the script.
(I'm using Ubuntu for Windows)
I've tried using sudo & sudo chmod a+x before the script, but this doesn't seem to help.
The error message indicates that perl is unable to read the contents of the file script.pl.
Since it is not clear who the script's owner is, you may give read permission to everyone using the following, sudo chmod a=rx path/to/script.pl.
I am currently working in a remote environment which has a user with certain sudo permissions for which it does not require inputting any password.
Specifically it can perform some nginx commands without the need of a password, so far so good. The problem I face comes when I have a python script that takes care of checking for updates and if there are changes tries to reload nginx. As seen below
Popen(['sudo', 'nginx', '-T'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
call(["sudo", "systemctl", "reload", "nginx.service"])
When the script reaches one of this steps a prompt pops up on the terminal asking for a password, which should not be necessary since the user running the script has the permissions to run the commands without inputting it.
Question: Is there maybe a way, without hardcoding the password in a variable, to tell the script to "inherit" the permissions of the user when I run it?
Some additional information:
If the script itself is invoked with sudo everything works, but sadly this is not an option and sudo should be used only for the specific parts that completely require it (nginx reloads)
Python version is 3.5
EDIT: Solved this thanks to a friend:
The solution was to add the 'shell=True' paramater to the Popen.
Popen('sudo nginx -T'], shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
The issue might be, that there is a mismatch in the sudoers nginx-path and the PATH variable used during script execution.
Try to either match the Popen call to the full PATH given in the sudoers file or adjust the PATH in the shell calling the Python script.
I'd like to write data to a file, but the file handle should be opened with access permissions for a specific user.
Thus, the following statement:
open (FH, "> $filename") or die "$#\n";
would allow writing to a file as that particular user.
Is there a way to do this within a Perl script, without the entire script being run with sudo -u $username?
There are two established ways. Stackers, you are invited to edit this answer to fill in the drawbacks for each.
Run the program with sudo. The first thing you do in the program is to open the files you need and keep the handles, and then immediately afterwards drop the root privileges. Any further processing must take place with low privileges. The Apache httpd works likes this, it opens the log files as root, but continues running as nobody or similar.
If you don't like that way, run the program normally, and when you need to elevate, create a new process and have it run with a user configured sudo, su -, kdesu/gksu or whatnot. The CPAN client works likes this, it fetches, unpacks, builds and tests a module as a normal user, but calls sudo make install etc. when it's time to install.
An alternative to daxim's suggestions is to have the script owned by the specific user and have the script permissions include the setuid and/or setgid bits.