How to make nscd generate core dump files? - core

nscd service crashed without a core dump file.
ulimit -c is unlimited.
Someone says that that's because nscd use "setuid" when the "server-user" is set in /etc/nscd.conf.
Then I added a "#" to delete it at the beginning of the "server-user" line in /etc/nscd.conf then restart the service.
Now it runs as root which could be checked by "ps -ef | grep nscd".
However, the following commands still could not make nscd to generate a core dump file:
kill -ABRT nscd-pid
or kill -s SIGSEGV nscd-pid
Who can tell me why and how? Thanks in advance!

resolved it myself. That's because nscd is called with "daemon nscd ..." in /etc/init.d/nscd script, however the daemon function in /etc/init.d/functions modify the core dump file size to be 0, so even if issuing "ulimit -c unlimited" at the beginning of "/etc/init.d/nscd" could not make sence.

Related

find -mtime option on linux listing all files regardless of time?

I'm trying to use the linux find command to show me the files in my current directory that have been modified in the last 24h. To test my command, I piped it to ls as below.
find . -maxdepth 1 -mtime -1 | xargs -I{} ls -lh {}
but this command displays all the files in my directory, some of which were modified last year. What am I missing here? I also tried -atime and -ctime options out of curiosity and got seemingly the same file list.
Many thanks for the advice!
In my case the issues was caused because I had the wrong system time on my raspberry.
This was because systemd-timesyncd.service was no longer running.
After:
sudo systemctl unmask systemd-timesyncd.service
sudo systemctl enable systemd-timesyncd.service
sudo reboot
the system time was correct again. Note that the pi needs to be connected to a network for this to work. And also, of course, past wrong file dates don't get fixed by this (duh).

catch console output from background process

I have a program running on armbian single board computer. The program starts with -b option during the startup of the system. I created this simple shell script
#!/bin/bash
#Myprog server start
sudo -b /home/myprog/myprog
This program is C written and it sometimes outputs some information with printf functions. But since it is started with -b option there's is noting in the console.
Now when I log in to the armbian via ssh with Putty I want to occasionally read the output of this program. Is it even possible?
Not exactly what you’re asking, but generally speaking it’s better practice to redirect output to a log file than to try to interactively look at the console output for a background app.
Something like:
sudo -b /home/prog/myprog >> /home/prog/log.txt 2>&1
Should do it.
Then view output with
tail -f /home/prog/log.txt
If it’s really important to you to run interactively without logs, I would suggest running it from within “screen” without backgrounding it.
screen
sudo /home/prog/myprog
Then ctrl-d to detach and let it run in background. screen -r to reattach.

Remotely launching a process with LLDB

I'm trying to remotely launch and debug a new process with lldb without much success.
Attaching to an already launched process works well by running these commands:
process connect <url>
process attach -P gdb-remote --pid <pid>
But if I want debugserver to launch the executable by itself I'm running into troubles. Especially, I have no clue what arguments should I pass to target create.
According to this page LLDB "will transparently take care of [..] downloading the executable in order to be able to debug", yet target create seem to always require a local file. If I specify the remote file via -r I get either unable to open target file or remote --> local transfer without local path is not implemented yet errors. If I set the target to a local file (such as a local copy of the remote's loader executable) without using -r, then attempt to run process launch -p gdb-remote -s <remote path> LLDB will attempt running the local path on the remote machine and fail.
What are the correct commands I need to use in order to launch a remote process?
After contacting LLDB's mailing list Greg updated the documentation page, which now clearly explains what I have to do (Specifically I was missing the script lines, which appear to be the correct way to set the remote executable path)

posix_openpt() - error - Cant access tty, job control turned off

I'm using a psuedo terminal, /bin/sh -i, by calling normal commands for posix_openpty() then fork(), in language C.
When I run from command line GUI terminal like this
$ ./MyTerminal
or
$ sudo ./MyTerminal
or as root like this
# ./MyTerminal
all works very good and as expected, no problems.
However, when I make a systemd service file like this, it works fine
[Service]
User=root
But when I try to get systemd to run it as normal user like this
[Service]
User=debian
THe first output for /bin/sh -i is
/bin/sh: 0: can't access tty; job control turned off $
And the terminal does not really work.
When I run /bin/bash, fork() w/posix_openpty() is returns me this, but the terminal generally works ok
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
Is such a weird prolem because when running outside of systemd everything works perfect. I see this problem in 1 other question but no clear solution. So what I have to change to make systemd run my file perfectly? Thanks for your help.

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

Resources