LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   firestarter and kde4 (https://www.linuxquestions.org/questions/linux-software-2/firestarter-and-kde4-846378/)

josephj 11-24-2010 06:32 PM

firestarter and kde4
 
I have kde set to restore my previous session when I login.

In my kde Autostart directory, I have a script that sleeps for a short while to let kde restore my session and then checks to see if firestarter is running. If not, it starts it using kdesudo.

Everything works fine except that every time I login I get two pop up windows. One says that firestarter can't start without root privileges and the other says that kdesudo is being run with no arguments. This is occurring as part of kde restoring my session - before my autostart script kicks in - like kde is treating the kdesudo process and the firestarter process separately.

Once I close these two windows, everything, including autostart starting firestarter, works fine.

I'm open to any solution to this.

What I thought I would do to fix this was to write a script to shutdown firestarter when I logout so that kde wouldn't try to restore it.

Code:

#!/bin/bash
## shutdown firestarter when kde exits
## to avoid messy next startup

kdesudo "kill $(ps -ef | gawk '/firestarter/&&/--starthidden/&&!/gawk/{printf "%s ", $2}END{printf ""}')"

This script works when I test it from the command line, but it has two problems:
1) Where is the best place to put it?
I tried putting it in ~/.kde/shutdown, but that didn't do anything.

2) Since it needs root permissions to shutdown firestarter, it needs to run when kdesudo still has access to my screen and time for me to type in a password. It also has to fail gracefully if I don't enter the password.

TIA
Joe

kubuntu karmic/firestarter 1.0.3/kde 4.3.5

mlangdn 11-24-2010 08:45 PM

I don't know anything about kubuntu, but does it have an /etc/rc.d/rc6.d shutdown script? That's where your script should go. Wherever kubuntu has its shutdown script.

josephj 11-25-2010 12:54 AM

Not sure that's the problem
 
I want to preface this reply with the fact that I'm pretty green with respect to startup/shutdown scripts.

In general, you're right that a system level utility like a firewall should be handled by init scripts.

There's a k20firestarter script in /etc/rc6.d and an s20firestarter in /etc/rc3.d But, I don't think that's the issue. If it was, wouldn't there be some sort of shutdown or boot up error condition? Is there something I should look for?

I'm not really sure, but I think firestarter itself is getting started and shutdown correctly at the system level through the init scripts.

What I'm doing (or trying to do) at the user level is to start the gui part that puts the firestarter icon in my task bar in my panel and lets me interact with firestarter. That's the part that kde sees. I don't think it is concerned - or even knows about anything in the init scripts. And, if there was a problem at that level, I don't think it would put anything on my user screen. It would show up in the system logs/dmesg, etc..

Please correct me if I am wrong or just looking in the wrong places, etc..

Joe

mlangdn 11-25-2010 04:10 AM

Try this link and see if this is what you are after:

http://www.fs-security.com/docs/faq.php

josephj 01-05-2011 06:48 AM

I had that all set up, but maybe it's incorrect. There may be a blank missing or needed in the part about firestarter.

Here's what I have in sudoers:

Code:

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Users can start the firewall with no password
bigbird ALL=NOPASSWD:/usr/sbin/firestarter
shelelia ALL=NOPASSWD:/usr/sbin/firestarter

My user is bigbird. It is a member of the admin group.

Here's part of what's in my $HOME/.kde/Autostart/mystart script which does all my startup stuff.

Code:

ps -f -u "$USER" > "$PS"  # the -f is necessary because most of the restores are done by kdeinit and the
                          # actual name of the application being restored just shows up as an argument
## Desktop Independent stuff

## Start the Firewall
sleep 10 ## Give Wifi a small chance to start up first
if [[ ! $(grep "firestarter" ${PS}) ]]
then
  kstart --iconify --skiptaskbar kdesudo "/usr/sbin/firestarter --starthidden"
fi

That works except for the --starthidden part. That's probably one of those weird quoting issues in bash.
If I take the quotes off, then kdesudo grabs the --starthidden option and complains that it doesn't exist.

If I can't fix the problem, I just won't run the gui unless I need to configure a new application, etc..

I found out that $home/.kde/shutdown is the place to put scripts for kde to run when it's closing (although I saw at least one comment saying that it doesn't work.)

What I don't know how to do is to close the firestarter gui from a script. It has a command line option that stops the firewall, but it doesn't close it and the gui keeps running.

I could use ps to get its pid and then kill it, but that doesn't sound like a very good idea to do on a regular basis and it would still have to be rigged somehow to run as root - preferably without asking me for a password every time I want to log out or shutdown. It all seems to come back to getting sudoers to work right.

Any ideas would be appreciated.

Joe


All times are GMT -5. The time now is 03:36 PM.