maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [Announce] Dalvik resetter + Profile changer for Sailfish (https://talk.maemo.org/showthread.php?t=92545)

Schturman 2014-01-29 02:19

[Announce] Dalvik resetter + Profile changer for Sailfish
 
Finally I did it, I'm sure it's far to be perfect, but here is my two first app :D
May will be useful for someone...

1. Alien Dalvik restart - It's just bottom for quick refreshing aliendalvik service.
v0.3
* sudo not needed anymore (used helper from meShell post, thanks)

2. Profile changer - This is a small One click app for changing profile to silent and back to general. You can put this icon where you can quickly find it instead go to lockscreen..

v0.5
* sudo NOT required anymore, this version also update icon on your homescreen (thanks to Coderus).

v0.4
* sudo NOT required anymore, but also can't change icon on your homescreen.

v0.2
* small changes in the commands

http://imagizer.imageshack.us/v2/800...0/838/up8e.jpg http://imagizer.imageshack.us/v2/800...0/607/attf.jpg


Download from my OpenRepos:
1. AlienDalvik restart
2. Profile changer

Beware, use it on your own risk !!!

PS. If someone can create more buty icons, I will repackage them...

szopin 2014-01-29 02:23

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by Schturman (Post 1409521)
Finally I did it, I'm sure it's far to be perfect, but here is my two first app :D
May will be useful for someone...

1. Alien Dalvik restart - It's just bottom for quick refreshing aliendalvik service.

2. Profile changer - This is a small One click app for changing profile to silent and back to general. You can put this icon where you can quickly find it instead go to lockscreen..


Both apps requared sudo installed on your phone. You can install it from mer-tools repository. (thanks to rcolistete)
Code:

$ devel-su
# ssu ar mer-tools
# ssu ur
# pkcon refresh
# pkcon install sudo

Also you need add this line: to:
Code:

nemo ALL=(ALL) NOPASSWD: ALL
to: /etc/sudoers (thanks to szopin)


That's all ;)


Download from my OpenRepos:
1. AlienDalvik restart
2. Profile changer

You should not require people to setup their privileged behaviour as yours. You could make your DL one line editable to insert password for those who don't need mer tools repo, or the change to how su is called.

And I seriosuly mean it, if someone follows your instructions just to install profile changer they should be aware they in the meantime allowed all semi-android(just make sailfish wrapper that runs 'sudo x') or other applications easy way in, this really should not be dep for anything

Schturman 2014-01-29 06:02

Re: [Announce] 2 small and useful (maybe) app...
 
Maybe you are right, I'm not developer and not so tech, I just did it because it was easy for me instead creating script with pass asking.
If you think it better to remove this post, I will remove..

PS. can you explain it please:
Quote:

just make sailfish wrapper that runs 'sudo x'

evk 2014-01-29 06:30

Re: [Announce] 2 small and useful (maybe) app...
 
It's not possible to use setuid?

Makeclick 2014-01-29 07:10

Re: [Announce] 2 small and useful (maybe) app...
 
reset alien is very good idea. its not that solid :D. many reboot because of that.

Boxeri 2014-01-29 07:21

Re: [Announce] 2 small and useful (maybe) app...
 
I also think that reset alien dalvik is really good idea! This is something that i do quite regularly on terminal because of connection problems on android side.

meShell 2014-01-29 07:37

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by evk (Post 1409538)
It's not possible to use setuid?

setuid( 0 )

It is possible, I am using this "helper" to start my "vpnc" with a GUI-Button, because I did not get a response and did not find any "recommended way to run as privileged" via Sailfis-App.

So there are 3 steps.
  • compile helper program
  • change owner to root:root
  • change permissions to 4755


Example (added example with 2 commands seperated by "&&"):

Code:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
  setuid( 0 );
  system( "/usr/sbin/vpnc && /sbin/ip route add xxx.xxx.x.0/24 dev tun0);

  return 0;
}


compiled it with gcc on the phone like this:

Code:

gcc vpnc-helper.c -o vpnc-helper
devel-su
chown root:root vpnc-helper
chmod 4755 vpnc-helper


Schturman 2014-01-29 07:41

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by evk (Post 1409538)
It's not possible to use setuid?

I don't really know how to do it...

My first target was to create working rpm file, that can be installable/uninstallable from desktop. Finally I got it...
But... when we press on the icon it run my script as USER and many commands I need to run as ROOT when I already user.. In my first version (sudo not installed yet) I used devel-su many times in one script, for example to run this command (echo silent > /usr/share/jolla-mods/temp) I needed write it like this to get it work:
Code:

echo rootme|devel-su -c sh -c "echo root|devel-su -c echo silent > /usr/share/jolla-mods/temp"
where is rootme = nemo user pass (from dev mode) and root = is root user pass
Too much weird combination :(
Now with sudo I run the same command like this (much easily):
Code:

sudo sh -c "sudo echo silent > /usr/share/jolla-profchanger/temp"
like you can see I used sudo twice because even I have sudo USER can't write to ROOT directory...

Also when and if I will learn how to package with root permission (I don't know what to write to .spec file for this), something like aegis manifest on N9, when after installation by pressing on the icon it will run script automatically as ROOT, it will be nice. But also here I have a problem.. For example this command we need to run as USER:
Code:

dbus-send --type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile string:"silent"
I tried a meany diff variation to get i work under ROOT, but without success :(

Schturman 2014-01-29 08:00

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by meShell (Post 1409551)
setuid( 0 )

It is possible, I am using this "helper" to start my "vpnc" with a GUI-Button, because I did not get a response and did not find any "recommended way to run as privileged" via Sailfis-App.

So there are 3 steps.
  • compile helper program
  • change owner to root:root
  • change permissions to 4755


Example (added example with 2 commands seperated by "&&"):

Code:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
  setuid( 0 );
  system( "/usr/sbin/vpnc && /sbin/ip route add xxx.xxx.x.0/24 dev tun0);

  return 0;
}

compiled it with gcc on the phone like this:

Code:

gcc vpnc-helper.c -o vpnc-helper
devel-su
chown root:root vpnc-helper
chmod 4755 vpnc-helper


Hmmm, thanks... don't sure If I understand it correctly, I need to create this files like your vpnc-helper to each command that I need to run as ROOT when I under USER?
For example in script included commands:
root command
user command
user command
root command
user command
Each root command is a different command, that mean I need a different my-helper files ?
And how I implement this and how to run this file in the script ?

Schturman 2014-01-29 08:16

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by Boxeri (Post 1409549)
I also think that reset alien dalvik is really good idea! This is something that i do quite regularly on terminal because of connection problems on android side.

This is exactly a reason why i did it :) It make me crasy when it happens while driving with waze and i needed to open terminal to restart it :D

PS. if someone can create more beauty icons it will be nice :p

nieldk 2014-01-29 09:02

Re: [Announce] 2 small and useful (maybe) app...
 
Never set SUID bit on shell scripts. Executing a shell script involves a two-step process 1) The kernel starts up a SUID copy of the shell interpreter 2) The shell interpreter begins executing the shell script. You can interrupt the kernel after the first step and switch the file that the shell interpreter is about to execute.

Schturman 2014-01-29 09:14

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by nieldk (Post 1409569)
Never set SUID bit on shell scripts. Executing a shell script involves a two-step process 1) The kernel starts up a SUID copy of the shell interpreter 2) The shell interpreter begins executing the shell script. You can interrupt the kernel after the first step and switch the file that the shell interpreter is about to execute.

Thanks for answer, but don't speak chines :D.
Sorry I'm not programmer and all this terminology is really chines for me. I'm simple noob user that like scripting a little and trying to find easy way to do some stuff in the system without typing password every time :o

strongm 2014-01-29 09:47

Re: [Announce] 2 small and useful (maybe) app...
 
Not sure I completely see the necessity for Profile Changer.

It's pretty easy to add sound settings as a favourite in Settings, and just leave Settings as a running app on the Home screen

andreas1 2014-01-29 09:52

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by strongm (Post 1409577)
Not sure I completely see the necessity for Profile Changer.

It's pretty easy to add sound settings as a favourite in Settings, and just leave Settings as a running app on the Home screen

true, but one click > more than one click, simple as that :)

Schturman 2014-01-29 10:20

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by strongm (Post 1409577)
Not sure I completely see the necessity for Profile Changer.

It's pretty easy to add sound settings as a favourite in Settings, and just leave Settings as a running app on the Home screen

Sure.. anyone deside for himself and I did it for myself ;) Just shared it, maybe someone also need it...

HtheB 2014-01-29 10:22

Re: [Announce] 2 small and useful (maybe) app...
 
Can you please change the thread title?
Like:
[ANNOUNCE] Dalvik resetter + Profile changer for Sailfish

Schturman 2014-01-29 11:39

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Done... ;)

Schturman 2014-01-30 09:00

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Just now noticed that if you display stuck and not going sleep, refreshing of aliendalvik can help too :)

Schturman 2014-01-31 22:04

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Profile changer updated..
v0.2 have some small changes in the commands..

Quaddy 2014-01-31 23:08

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
thanks for these, god i hope profilematic comes to sailfish, so then i can automate / time this profile thing to have basic quiet hours!

p.s after new update, profile one doesnt work for me, dalvik resetter does still thought :(

p.p.s uninstall and re-install has it working again :):p

Schturman 2014-02-01 01:26

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Ok, I tried to create new version and using helper instead SUDO from meShell post.
For Alien Dalvik it work without any problem (update will be uploaded soon, but in the profile changer I have one little problem, Desktop icon & text not updated :( All commands work like expected, it change icon and create new .desktop file for silent or general when you press again on the icon. It just leave empty icon with same text on the desktop. In the version with sudo usage all work like should to work, it also updated desktop icon and text.

How to cause update of the icon on the desktop without refresh of homescreen ?

EDIT: Nevermind , got it :) (update soon)

EDIT2: No.. it still not work :(

Schturman 2014-02-01 02:39

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Dalvik resetter updated..

v0.3
* sudo not needed anymore (used helper from meShell post, thanks)

Boxeri 2014-02-01 08:18

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Nice job

seems to be working correctly

Schturman 2014-02-01 23:42

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Update:
v0.4 (Profile changer)
* sudo NOT required anymore, but also can't change icon on your homescreen.

jayki 2014-02-03 19:24

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Could you please make the source public?
I think alien resetter is just a litte "systemctl restart aliendalvik.service, but i'd like to see how exactly you make the root think, i just don't understand the steps posted on page 1 :O
Would be helpful for my app :)
Thank you :)

Schturman 2014-02-07 22:16

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Quote:

Originally Posted by jayki (Post 1410698)
Could you please make the source public?
I think alien resetter is just a litte "systemctl restart aliendalvik.service, but i'd like to see how exactly you make the root think, i just don't understand the steps posted on page 1 :O
Would be helpful for my app :)
Thank you :)

This is my helper file:
Code:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
  setuid( 0 );
  system( "systemctl restart aliendalvik.service");

  return 0;
}


Schturman 2014-02-07 22:17

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Update:
v0.5 (Profile changer)
* sudo NOT required anymore, this version also update icon on your homescreen (thanks to Coderus).

JjyKs 2014-02-08 05:00

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Thanks for Dalvik reset, i was already annoyed by constant "systemctl restart aliendalvik.service"

http://i.imgur.com/VKhyeWm.png
http://i.imgur.com/Azca3NI.png

Two icons i made quickly. No idea if you wanted to stick with orange theme, but i did these to fit my personal favorite ambience :p

Edges seem to be a bit rough, but so did the icon_launcher_template file, so i think that it isn't noticeable on phone screen

TMavica 2014-02-08 06:29

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
there is a new app in jolla habour call killdroid

Schturman 2014-02-09 11:18

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Quote:

Originally Posted by TMavica (Post 1411616)
there is a new app in jolla habour call killdroid

probably it's do the same like my..

Schturman 2014-02-10 08:30

Re: [Announce] 2 small and useful (maybe) app...
 
Quote:

Originally Posted by meShell (Post 1409551)
setuid( 0 )

It is possible, I am using this "helper" to start my "vpnc" with a GUI-Button, because I did not get a response and did not find any "recommended way to run as privileged" via Sailfis-App.

So there are 3 steps.
  • compile helper program
  • change owner to root:root
  • change permissions to 4755


Example (added example with 2 commands seperated by "&&"):

Code:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
  setuid( 0 );
  system( "/usr/sbin/vpnc && /sbin/ip route add xxx.xxx.x.0/24 dev tun0);

  return 0;
}

compiled it with gcc on the phone like this:

Code:

gcc vpnc-helper.c -o vpnc-helper
devel-su
chown root:root vpnc-helper
chmod 4755 vpnc-helper


I have a question, can we do something similar to run command as USER under root? For example, the dbus command I should run as user, but I now under root.
in N9 it was simple, devel-su user -c "comnand" and it didn't ask about password.
Can we do something similar on Jolla?
thanks

Schturman 2014-02-10 20:34

Re: [Announce] Dalvik resetter + Profile changer for Sailfish
 
Ok, found it :D
When you are ROOT and if you want to run command that should be run as USER, you can use this command:
Code:

su -l nemo -c "your command"
:D


All times are GMT. The time now is 10:40.

vBulletin® Version 3.8.8