Right now, a user must run my installer as superuser with sudo, gksudo. su or other utility on a Linux. Can I change my installer so users can start the installer as a normal user, then be prompted to enter his password and change to superuser rights?

asked 09 Dec '12, 21:23

tahoar's gravatar image

tahoar
201313236
accept rate: 42%

Can't change the selected answer. Please check-out andny's update. It replaces the use of deprecated gksu.

(31 May '16, 12:19) tahoar

One option is to run gksu or kdesu when detecting the installer is not run as root. For example:

<initializationActionList> <actionGroup> <actionList> <throwError text="Please, launch the installer as root"> <ruleList> <programTest name="gksu" condition="is_not_in_path"/> <programTest name="kdesu" condition="is_not_in_path"/> </ruleList> </throwError> <runProgram program="gksu" programArguments="${installer_pathname} &amp;" > <ruleList> <programTest name="gksu" condition="is_in_path"/> </ruleList> </runProgram> <runProgram program="kdesu" programArguments="-c ${installer_pathname} &amp;" > <ruleList> <programTest name="gksu" condition="is_not_in_path"/> <programTest name="kdesu" condition="is_in_path"/> </ruleList> </runProgram> <exit/> </actionList> <ruleList> <isFalse value="${installer_is_root_install}"/> </ruleList> </actionGroup> </initializationActionList>

This will restart the installer using kdesu/gksu if any of them are in path and will throw an error (which will show a graphical dialog or print the error on console for text mode) if none of the commands are found.

link

answered 10 Dec '12, 02:40

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Excellent. It works great. Thank you.

(10 Dec '12, 05:05) tahoar

Question: the above code does not execute with the uninstaller. I added the code to the <preUninstallationActionList> and it runs. However, this action list causes the uninstaller to prompt the user for uninstall options twice. Is it possible to update InstallBuilder to run an actionlist on uninstall before prompting the user for uninstall options?

(08 Jan '13, 11:30) tahoar

Currently it is not possible to run actions before uninstaller confirmation question and/or component selection is shown.

If you are using confirmation, you can simply disable the confirmation dialog and show your own confirmation dialog after the actions to run gksu/kdesu commands (i.e. only if installer is already running as root).

For component selection, currently there is no option to enable this.

(09 Jan '13, 05:26) wojciechka ♦♦

I updated the code slightly to return any exit code to the shell.

<initializationActionList>
    <actionGroup>
        <actionList>
            <throwError text="Please, launch the installer as root">
                <ruleList>
                    <programTest condition="is_not_in_path" name="gksu"/>
                    <programTest condition="is_not_in_path" name="kdesu"/>
                </ruleList>
            </throwError>
            <if>
                <actionList>
                    <runProgram program="gksu" programArguments="${installer_pathname} &amp;"/>
                </actionList>
                <conditionRuleList>
                    <programTest condition="is_in_path" name="gksu"/>
                </conditionRuleList>
                <elseActionList>
                    <runProgram program="kdesu" programArguments="-c ${installer_pathname} &amp;"/>
                </elseActionList>
            </if>
            <exit exitCode="${program_exit_code}"/>
        </actionList>
        <ruleList>
            <platformTest negate="1" type="windows"/>
            <isFalse value="${installer_is_root_install}"/>
        </ruleList>
    </actionGroup>
</initializationActionList>
link

answered 30 Dec '12, 05:16

tahoar's gravatar image

tahoar
201313236
accept rate: 42%

hi this is very similar to what I was looking for but I´m having the next problem: the gksu is prompting well but when i put the root password correctly it desappear and the other screens of the installer are never shown. I´m working with the second code. Another: ¿what really the program_exit_code does ?

link

answered 25 Apr '13, 22:11

Frank%20Ernesto%20Matos's gravatar image

Frank Ernest...
26112
accept rate: 33%

There are many different Linux distributions. You might have to experiment with the parameters of the gksu or kdesu commands to make them work. The program_exit_code is a variable with the exit code returned from the most recent external program you executed from within the installer. This is always an integer. zero (0) means the program competed without error. non-zero typically means the program had an error, but each program will give different numbers.

(26 Apr '13, 12:10) tahoar

In this line <runprogram program="gksu" programarguments="${installer_pathname} &amp;"/> what the & is for??

link

answered 25 Apr '13, 23:02

Frank%20Ernesto%20Matos's gravatar image

Frank Ernest...
26112
accept rate: 33%

The & indicates that the program should be run in the background - similar to how it works in Windows command line and Unix shells.

(26 Apr '13, 02:43) wojciechka ♦♦

gksu is now deprecated. I changed to this.

<actionGroup>
    <actionList>
        <throwError text="Please run the license initialization script as root after the installation">
            <ruleList>
                <programTest condition="is_not_in_path" name="pkexec"/>
            </ruleList>
        </throwError>
        <runProgram program="pkexec" programArguments="${license_init_script}">
            <ruleList>
                <programTest condition="is_in_path" name="pkexec"/>
            </ruleList>
        </runProgram>
    </actionList>
    <ruleList>
        <isFalse>
            <value>${installer_is_root_install}</value>
        </isFalse>
    </ruleList>
</actionGroup>
link

answered 27 May '16, 07:39

andny's gravatar image

andny
1
accept rate: 0%

1

Thank you very much andny! I knew gksu was deprecated but I've been too busy to look-up its replacement. I tried changing the preferred answer to this one, but it didn't work. -- Tom

(31 May '16, 12:18) tahoar
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×155

Asked: 09 Dec '12, 21:23

Seen: 2,204 times

Last updated: 31 May '16, 12:19