incrond running but not executing command under CentOS 6.4 - bash

I have installed incron from the EPEL repository (before you ask; YES, I also tried downloading the source and compiling locally; same results) and am attempting to set up a process on my CentOS 6.4 (final) virtual box that I have successfully prototyped on my local Ubunto 12.04 machine:
Some information up front:
SELinux is set PERMISSIVE
I have added my script(s) and called executables to all with NOPASSWD using visudo to get around some permissions issues...
If I invoke my script from the command line with sudo /path/to/my/script.sh arguments it works like a charm.
sudo service incrond status verifies that incrond is running. root and myusername are added to /etc/incron.allow, /etc/incron.deny is empty.
My incrotab for root is:
/path/to/dropfolder/ IN_CLOSE_WRITE sudo /path/to/my/script.sh $#/$#
Events in /path/to/dropfolder/ result in exactly NOTHING happening. No logs are generated, no messages, no actions occur on the files in the folder.
So I have researched: it was suggested that cron runs in a minimal environment and that to execute complex commands/scripts you may have to execute your .bashrc and/or export your PATH at the beginning of the cron command.
Note: I can find no documentation supporting that incron also runs in a minimal environment, but as my google-fu (and bing-fu!) failed to result in any helpful results related directly to incron I figured WTH, I'll try that!
Edit: Documentation indicates that incron run from system tables or root takes env from its host enviroment, therefore only incron executed by non-root users should require any sort of env or PATH fiddling
So… incrontab for root:
/path/to/dropfolder IN_CLOSE_WRITE . /home/myusername/.bashrc; export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin; sudo /path/to/my/script.sh $#/$#"
No dice… tried && instead of ; = no dice. If you can think of a variation on the above I've probably tried it…
So, lets try a little restorecond -R /usr/sbin/incrond /etc/incron* action!
Huh, no change there either.
service incrond stop followed by service incrond start and then service incrond restart … nope, nope, and nope.
Drastic measures: yum remove incron and yum install incron, chkconfig incrond on and then for good measure a sudo reboot!
Nothing.
I don't even get anything from /tmp/ IN_ALL_EVENTS echo boo>>/home/myusername/boofile.txt, hence my inability to even do an env>>envfile.txt to check whether incron is running in a sparse environment… (see above note)
And yet: service incrond status yields incrond (pid xxxx) is running...
What am I missing? It has to be big and obvious and I hope someone can make me feel like an idiot in short order!
further examination of /var/log/cron yields results like this: Aug 14 15:05:30 hostname incrond[1584]: (root) CMD (sudo /path/to/DropFolder/script/subfolder/script-Beta-1.sh /home/username/DropFolder/testfile.file) -yes I made sure my script was executable..
so incrond is indeed attempting to do SOMETHING, but I get no output anywhere... even a simple echo > /dev/pts/0 produces nada results.
thanks for fixing my crap formatting job

Ok, here's the answer:
Despite all documentation I can find declaring it to be the contrary, incrond under CentOS 6.4 runs in a sparse environment and behaves as cron. this is NOT the case under Ubuntu, where incron inherits its environment from root for system tables and root tables and only user tables run in a sparse environment. This of course means that if you're calling a script (I am) the script needs to build it's environment and every thing must have a full path. EVERYTHING. (well, except for shell builtins :p)
numerous Google and and Bing and Stack Overflow and Server Fault searches all told me that cron operates this way, but they all also seemed to indicate that incron operates as described in the documentation, which it DOES under Ubuntu...
Bottom line, it works now, yay!
I guess this just goes to show: when in doubt define the environment and use full paths... er, actually, just do that all time and save yourself a headache.
(this does not address my problem with applying a SELinux security policy for incron, but I'll worry about that later, in another post...)

Related

Git installation failed [duplicate]

I am new here and i will try to explain my question kindly ignore any mistakes.
I am using git version git-2.8.2
It worked fine for one day then this problem occurs.
I am using gcloud repository.
First I tried gcloud clone command then this error occurs
Then to make sure git is there I tired git command then this error occurs
Then I double check by opening git Bash but same error was there too.
I tried reinstalling changing directory. but nothing works.
I face the same problem after I try to avoid memory leak in Windows 10. If you happened to change the regedit like me, just type regedit in the search then go to
HKEY_LOCAL_MACHINE -> SYSTEM -> ControlSet001 -> Services -> Null
change the value of Start to 1.
I accidentally bumped into the same problem when I was sorting out the services running on my computer with Windows 10.
fatal: open /dev/null or dup failed: No such file or directory
The reason was that I deleted the service named 'Null' that had no description as I thought that was a virus service.
Thus, when I found my git unable to operate, I reckoned the deleted service.
According to a solution provided on some site I tried to run the service again using cmd.exe
sc config Null start= system
sc start Null
but it said the service hadn't been existed in the list.
Thankfully, there are some kind folks who shares the information of the default services running on Windows 10 and the description necessary for the successful bringing back the service.
So as to get the service back in the list:
press Win + R
type regedit
go to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services section
Create Null folder and all the params it needs.
Restart your computer.
Now you got your Null service back and your git back as well.
Hope this helps.
I solved my problem accidentally. I would like to share it with everyone.
It was not a problem of git or gcloud or source tree.
Actually I have forcefully stooped windows update from installing which causes this problem.
Now when I install windows updates again this problem is fixed now.
Maybe this helps someone.
the similar situation in chrooted linux tree is fixable following way:
cd inside the folder where you are preparing the chroot dir, then
mount -o bind /dev dev/
then only chroot inside
I had this weird bug just now. I went back a dir and tried git init, it worked there.
I re-ran zsh and tried again in the dir it errored in originally and it worked. shrugs

Running certbot-auto without being root

I'm running into permissions issues renewing my certs with certbot-auto, because whenever it runs it displays this message:
Requesting to rerun certbot-auto with root privileges...
There is no need for it to run as root, because the user running the command has permissions on all directories used by certbot. I couldn't find any command-line options to disable this, but looking at the script itself I discovered that when it re-runs itself it checks for the argument
--cb-auto-has-root and if it's there it doesn't try to obtain root (again). I found that if I run certbot-auto with this command it runs just fine as non-root!
But I'm not sure if this workaround should be used - since it's undocumented - or will break in the future. What's the recommended way to run as a non-root user?

Ros Environment in root

I have a ros (kinetic) environment set up on a raspberry pi 3 and am trying to get ros to execute upon startup via a simple bash script which calls roslaunch. Ros works in the user domain but fails when called from root.
Here is my launch_ros.sh script:
#!/bin/bash
source /home/pi/ros_catkin_ws/devel/setup.bash
export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
roslaunch my_pkg pkg_launch.launch
When I run sudo /home/pi/Desktop/ros_launch.sh the roscore crashes with
ERROR: cannot launch node of type [rosout/rosout]: can't locate node
[rosout] in package [rosout] failed to start core service [/rosout]
The traceback for the exception was written to the log file
But, if I comment out
source /home/pi/ros_catkin_ws/devel/setup.bash
and execute /home/pi/Desktop/ros_launch.sh, ros works fine.
Also worthy of noting is if I leave the above source line uncommented when running in the user domain I get the same error as I do in the root. I think this might be pointing me to the solution but I am still very new to ros.
Has anyone come across this issue and found a solution?
In order to run a node as root after changing your shell to root using commands like sudo -i, You can source your current bash profile thats located inside your normal user .bashrc and use it inside root shell.
Try the following code:
#!/bin/bash
source /opt/ros/kinetic/setup.bash
source /home/pi/ros_catkin_ws/devel/setup.bash
export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages
roslaunch my_pkg pkg_launch.launch
You need to source your workspace devel to be able to find your own package.
But, you need to source ROS devel to be able to use roscd, roslaunch, ...
In the code below I added:
source /opt/ros/kinetic/setup.bash
to source ROS and be able to use it.
PS: If it's still not working you should try a short delay before running roslaunch.
I was accidentally in a conda environment (base only) and it was messing up big-time. Try disabling any Python virtual environments.
It really worked and it inspired me to report that I didn't have rosnode as a program when I was planning to call ROS scripts in my own applications. Calling source .bashrc directly from the Raspberry Pi's system would refresh the terminal, but there was no way for my program to take over. The solution was to place the required ROS environment scripts in a separate script like name init_env.sh and then call source init_env.sh before any other ROS scripts were executed.

Run Jenkins' Cygwin script as user

I have Jenkins running on Windows, and I have a build that works fine under CygWin bash from the CygWin terminal, so I now want to automate it. However, using this script:
#!C:\cygwin\bin\bash.exe
whoami
make
The system reports me as nt authority\system, not the ken that I get when using an interactive shell. Is there an easy way to persuade Jenkins or CygWin to run as me?
Most likely you are running jenkins with default installation. You have two options. First is mentioned in the comment. Change the "Service account" to be same as yours.
Second option is derived from best practices. Run the jenkins master on a system with backup etc. Configure slave node with your account credentials. Change the project configuration to build on the specific node.
(It is possible to run slave and master on same machine with different credentials - just in case you want to try out things)
The real problem I was having was not that the shell script was running as the wrong user, but that the shell script was not executing the default /etc/profile. So, the solution was simply:
#!C:\cygwin\bin\bash.exe -l
whoami
make
I was still nt authority\system, but now I had the correct environment set up and could run make successfully.
Note also that if I create a /home/system directory I can add .bash_profile, etc, to that directory to further customise the build environment.

How to check Mesos Master?

I'm new to Mesos. I would like to know how do I know whether Mesos master is set up correctly in the node?
I have follow the set up given by http://mesos.apache.org/gettingstarted/
I am unable to run the following command:
Comment: Start mesos master (Ensure work directory exists and has proper permissions).
$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
but it shown error given:
./bin/mesos-master.sh: line 24: /home/user/mesos-0.20.0/build/src/mesos-master: No such file or directory
What ways should I proceed?
First, a few questions to help us debug your build:
Did the mesos build (make) complete successfully, and did make check pass all the tests?
If /home/user/mesos-0.20.0/build/src/mesos-master does exist, do you have execute permissions on it?
Are you running ./bin/mesos-master.sh from within /home/user/mesos-0.20.0/build/, or did you move the directory elsewhere?
If this is your first attempt at Mesos and you just want to run it and try it out (rather than fix bugs and develop features for it). I would recommend using a pre-built or cloud-deployed version of Mesos, rather than trying to build it yourself. See:
http://mesosphere.com/downloads/
http://mesosphere.com/downloads/details/index.html#apache-mesos
I'd suggest to follow Mesos Getting Started documentation.
After your system requirements are satisfied, following the section:
System Requirements
Once you reach the following section:
Building Mesos
when you execute the make without disabling verbosity, ensure that all process completed successfully. If it stops (e.g. tipically for proxy related issues) try to fix it accordingly or otherwise post your stack somewhere and I would be happy to help (if I can).
Unfortunately, running make check could not reveal the problem sometimes.
Have you run the make check command ? It is said in the documentation that the binaries will only be available after running the make checkcommand.Ì faced the same issue and it was because i didn't run that command.

Resources