×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    69

    [Solved] Run command as user during deinstallation of app

    How can I run a command as user "user" during the de-installation of my app?

    Since my App modifies the wallpaper, I want to restore the default one during de-installation.
    How ever, in the lastest beta of PR1.2 (28.2012.03-1_PR_001), root is not allowed anymore to modify files belonging to user.
    rm /home/user/.wallpapers/wallpaper.png
    shows:
    Permission denied

    Because of that, I can not do it anymore in the postrm script of the deb file.
    Or is there a way with aegis-exec?
    I tried it with
    exec /usr/bin/aegis-exec -s -u user /opt/myapp/bin/myapp
    but it didnt work.


    I succeeded to run the command as user with a daemon stop command, this then how ever gets run every time the user shuts down the device or the daemon gets stopped.
    I would prefer only to run it on a real de-installation.
    Last edited by CaCO3; 2012-02-10 at 18:33. Reason: solved

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Run command as user during deinstallation of app

    For giving your postrm script the permissions for to remove files as user,
    the tokens you have to provide is UID::user
    if it's needed you can give to it even GID::users

    Try adding the below to the aegis file -
    INSTALL context is for debian maintainer scripts.

    <request context="INSTALL">
    <credential name="UID::user" />
    <credential name="GID::users" />
    </request>
    Last edited by kusumk; 2012-02-10 at 12:13. Reason: rephrasing

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    69

    Re: Run command as user during deinstallation of app

    Thank you very much for your quick reply and the hint.

    So its the same way as used for other aegis credentials?
    I use that file already for my daemon and understand I only would have to add the line for the postrm script:
    Code:
    <aegis>
      <request>
        <credential name="UID::user" />
        <credential name="GID::users" />
        <for path="/opt/theword/thewordd "/>
        <request context="INSTALL">
      </request>
    </aegis>
    But then the whole postrm script will run as user?
    What if I also need to do operations as root?

  4. #4
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Run command as user during deinstallation of app

    I think best option is to create a bash script and add it to your debian package.
    The script is installed on the device and it's launced by the prerm script.
    You can give user capabilities to the script by defining a manifest file similar to the one you pasted in your post.

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    69

    Re: Run command as user during deinstallation of app

    You speak about a manifest file.
    Would that be a separate file?
    Or would it just be an extra line like
    Code:
    <for path="/opt/theword/user_restore_wallpaper"/>
    in the above mentioned file?

    Your idea about prerm brings me how ever to a new idea:
    I could run prerm with user rights and postrm with root rights.

  6. #6
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Run command as user during deinstallation of app

    A debian package can have only one manifest file.
    So if you have already one aegis file, you have to add a line to it.

    Wait, the solution proposed to kusuma btw adds user capabilities to all debian scripts.
    Which means they have root/user caps at same time.

  7. #7
    Registered User
    Join Date
    Jul 2011
    Posts
    69

    Re: Run command as user during deinstallation of app

    Thank you both for your help.
    I got it working now.

    How ever, unlike gnuton stated, if I add credentials to run the install scripts as user, they will lose their root rights!
    I added a "whoami" into the postinst and prerm scripts and it then showed "user" and failed the root operations.

    NB: When I set the user credentials once, the system kept it like that, even after I uninstalled/reinstalled the package.
    I had to force the credentials back to "root" once to get it back to the normal behaviour.

    The way to still get both rights is to run the install scripts as root and from within run another script with the rights of the user.

  8. #8
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Run command as user during deinstallation of app

    I guess aegis-exec -s root could force script to run a secondary script as root, or other users if you give right capabilities to the maintainer scripts.

  9. #9
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    151

    Re: Run command as user during deinstallation of app

    Quote Originally Posted by kusumk View Post
    For giving your postrm script the permissions for to remove files as user,
    the tokens you have to provide is UID::user
    if it's needed you can give to it even GID::users

    Try adding the below to the aegis file -
    INSTALL context is for debian maintainer scripts.

    <request context="INSTALL">
    <credential name="UID::user" />
    <credential name="GID::users" />
    </request>
    Hi,kusumk
    If i want to mkdir when installing, i have a "postinst" file, in the file are:
    #!/bin/sh

    set -e

    if [ -d "/opt/MyApp/db" ]; then
    echo "Folder exists!"
    else
    mkdir -p /opt/MyApp/db
    chmod -R 777 /opt/MyApp/db
    fi

    Now, i install my Application used Terminal, it failed and error info: mkdir can't create directory /opt/MyApp/db Permission denied.
    In my manifest.aegis file:
    <request context="INSTALL">
    <credential name="UID::user" />
    <credential name="GID::users" />
    </request>
    If I want to mkdir when installing , i need add something else in my manifest.aegis file?!
    Keep Smiling To Life!

    Dynasty1215

  10. #10
    Registered User
    Join Date
    Nov 2011
    Posts
    48

    Re: Run command as user during deinstallation of app

    A reply to both your two topics at once, along with this: http://www.developer.nokia.com/Commu...user-s-devices because the answer is the same.

    You are trying to create a folder in /opt/ so you cannot use UID::user and GID::users because "user" does not have enough privileges to mkdir inside /opt/

    I would suggest you create a folder inside /home/user, ideally called /home/user/.yourapppackagename and store all your app's data there. In this case UID::user and GID::users will work fine, your application installer should not be rejected by aegis, and you will have no neccessity to use chmod in your postinst.
    Last edited by conxt; 2012-05-08 at 11:18.

  11. #11
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    151

    Re: Run command as user during deinstallation of app

    Quote Originally Posted by conxt View Post
    A reply to both your two topics at once, along with this: http://www.developer.nokia.com/Commu...user-s-devices because the answer is the same.

    You are trying to create a folder in /opt/ so you cannot use UID::user and GID::users because "user" does not have enough privileges to mkdir inside /opt/

    I would suggest you create a folder inside /home/user, ideally called /home/user/.yourapppackagename and store all your app's data there. In this case UID::user and GID::users will work fine, your application installer should not be rejected by aegis, and you will have no neccessity to use chmod in your postinst.
    Thx , I think you said to me is correct. But is the home/user/myapppackagename/ dir is ervryone can access?
    Keep Smiling To Life!

    Dynasty1215

  12. #12
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Run command as user during deinstallation of app

    Yes, it is accessible

Similar Threads

  1. Deinstallation of shared SIS files
    By NevenS in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 11
    Last Post: 2010-03-31, 18:00
  2. User Defined Menu Command of Form not recognized
    By AptAmogh in forum Symbian User Interface
    Replies: 3
    Last Post: 2009-10-27, 08:00
  3. User command
    By sr_blar_mula in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2006-11-02, 17:33
  4. Font deinstallation
    By tolnaisz in forum Symbian
    Replies: 2
    Last Post: 2004-02-18, 15:46
  5. Nokia 31 and SMS / USER Command
    By sjscti in forum Nokia M2M
    Replies: 1
    Last Post: 2003-06-04, 12:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×