Killing an App
-
Hi,
I'm new in programming apps (Qml and Python) for this cool platform.
My little app should stop the music player after a certain time. The GUI in Qml is fine but the app has no permission to kill the music player withos.kill(i.pid, signal.SIGTERM)
(in a Python module).
I think it's because of AppArmor.My questions are:
Can I change the policies of AppArmor that it allows me to stop the music player ?
Or is there a workaround so that I start my app as sudo (similar to the UT Tweak Tool) ?
I've tried a bash script in terminal as sudo and it works fine with these steps:- Getting the pid of music player
- Stopping AppArmor service
- Kill -9 pid
- Starting AppArmor
Thanks for your support.
-
@digi6622 said in Killing an App:
I'm new in programming apps (Qml and Python) for this cool platform.
Welcome on board! Have you already read some about application confinement?
There are no app armor policy groups that would allow your app to do what you are attempting.
If your app is for personal learning and use then you could go the way of UTTT. Otherwise the functionality might more properly be proposed to the Music App, to stop playing after a certain time.
But without more information as to the goal it is difficult to offer guidance.
-
@arubislander
Thanks for your answer.Welcome on board! Have you already read some about application confinement?
There are no app armor policy groups that would allow your app to do what you are attempting.Now, I've read it . It is a pity that it is not supported by AppArmor.
If your app is for personal learning and use then you could go the way of UTTT.
Yes, this is my idea but I can't comprehend the steps of UTTT to become sudo, to forward the root-rights to the python module. I am still too inexperienced in programming for that.
Otherwise the functionality might more properly be proposed to the Music App, to stop playing after a certain time.
That's a good idea, too. But my little timer app should be my first attempt at programming on this platform and I would like to solve the problem.
But without more information as to the goal it is difficult to offer guidance.
Here is a short description:
- Calling the app with sudo-rights
- Chose minutes till shutting down the MusicPlayer
- Go sleep for ...minutes
- Stop AppArmor service in python(with root-rights)
- Kill MusicPlayer
- Start AppArmor service in python(with root-rights)
All code is already finished. The problem is point 4 and 6.
Thanks again.
-
@digi6622 said in Killing an App:
All code is already finished. The problem is point 4 and 6.
Not wanting to discourage you or anything, but the OS is specifically designed to make it difficult for an app to steps do 4, 5 and 6. In fact, if you could do steps 4 or 6, you wouldn't need to do them in order to do step 5, because your app would be unconfined to begin with.
As a learning tool, this if fine of course. But it seems to me that killing an app in order to stop music playback is quite drastic, no? And what you learn might be more valuable if you learn to do it within the confines set out by the OS.
Might I suggest instead you try to think of a way to achieve your goal without trying to circumvent the security structures of the OS?
Audio is typically handled by the media-hub. Is this the process you are trying to terminate? How about instead of that, you provide an empty playlist to media-hub to play from your application? I am not sure that would work, but if it does, it would stop the playback without needing your application to be unconfined. -
@arubislander
Yes, you are right: It is drastic to kill an app. But it seemed the simplest solution. Okay, I was wrong.I will search the net for the media-hub or Pulseaudio, maybe I can control it via python. Thanks for your suggestions.