Launch from Windows installer fails to drop privileges

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Launch from Windows installer fails to drop privileges

Post by uwestoehr »

sgrogan wrote: Sat Aug 21, 2021 8:54 pm At any rate, starting a previous version as admin doesn't make sense to me.
How should this be possible? The option for an immediate start of FC takes the just installed freecad.exe. If not you managed to break the Windows registry for the freecad.exe. Having several FC installations side by side works and is a core feature of the installer that people can have the stable FC 0.19 running and try out the new stuff in the FC 0.20 development version.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Launch from Windows installer fails to drop privileges

Post by chrisb »

To me installing and afterwards starting FreeCAD are two independent things, the latter being just a convenience function. So I would indeed expect to install as admin, but run the program as the normal user.
If you can switch to Admin privileges, I am quite sure that you can switch back as well.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Launch from Windows installer fails to drop privileges

Post by uwestoehr »

chrisb wrote: Sun Aug 22, 2021 12:25 pm If you can switch to Admin privileges, I am quite sure that you can switch back as well.
This is not that easy. You actively chose to be the admin, so all programs you start being an admin, have admin privileges. And as what user of the maybe dozen users of the Windows system should the program be started?
As admin you know what you are doing. So if you don't like to start FC after an installation for all users, then don't do this. If you do, you can check if the installation was successful and this is what the installer option is fore.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Launch from Windows installer fails to drop privileges

Post by chrisb »

uwestoehr wrote: Sun Aug 22, 2021 7:44 pm And as what user of the maybe dozen users of the Windows system should the program be started?
If the whole installation is started as admin, then of course the program will be finally started as admin as well. If the installation is started as regular user xyz, and then during installation the you switch to the admin user, then I would expect to run FreeCAD as user xyz.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: Launch from Windows installer fails to drop privileges

Post by uwestoehr »

chrisb wrote: Sun Aug 22, 2021 9:19 pm If the whole installation is started as admin, then of course the program will be finally started as admin as well. If the installation is started as regular user xyz, and then during installation the you switch to the admin user, then I would expect to run FreeCAD as user xyz.
This is not possible. Once you switch to be the admin your are independent of all user accounts. That is clear since you install for all users. Everything you do from then on affects all users of your system, of course also the start of FC.
If you are admin but don't want to start FC as admin, then just don't do this. You cannot blame the OS of following your will. And how should the OS know that you have a running instance of a program with admin privileges should not be run as admin and from what user account?

Again, start the cmd.exe from a user account and lift it to admin privileges. Then start a program of your choice, e.g. python.exe from it and you will see it has admin privileges as well. Just imagine you started the cmd.exe from being user number 12 but lift it to admin level. Then you are admin and thus detached from user accounts since you work from now on for all users. But now you want now start python.exe as being user number 12. Well, then then just stay as user number 12 and run python directly.
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: Launch from Windows installer fails to drop privileges

Post by chrisb »

It is possible that Windows cannot do what others can do. On linux you can e.g.
- start a command shell
- switch to admin, which starts a subprocess
- end the subprocess
- continue as previous normal user

It doesn't sound like rocket science to me, but if it is not possible, so be it. Then I would not offer to run FreeCAD automatically. You may know what's happening behind the scenes, but I would not infer from saying that a program should be installed for all users, also implies that it should be run as admin.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
curtmcd
Posts: 14
Joined: Tue Aug 17, 2021 11:25 pm

Re: Launch from Windows installer fails to drop privileges

Post by curtmcd »

Hi uwestoehr,

The Launch button is a convenience function for the user installing it. No user would expect the application to continue on as Administrator, as there is no valid reason ever to run it as Adminstrator. We'd be hard pressed to find another installer that behaves that way. They either launch as the user (for example, 3D Builder, Adobe Acrobat DC), or do not offer a Launch convenience (e,g., Inkscape, OpenSCAD).

Since there is already a comment in the installer code (posted above) acknowledging this issue, and written as if the launch feature is disabled when it isn't, and suggesting the workaround of forking a different process for UAC, I'd suggest just removing the launch feature. That would also absolve FreeCAD from the issue of which version gets launched when multiple are installed.
curtmcd
Posts: 14
Joined: Tue Aug 17, 2021 11:25 pm

Re: Launch from Windows installer fails to drop privileges

Post by curtmcd »

The main part of this bug is submitted here: https://tracker.freecadweb.org/view.php?id=4739
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Launch from Windows installer fails to drop privileges

Post by GeneFC »

Two comments.

I guess I am invalid, since I always run FreeCAD as Administrator. My choice, not yours. :shock:

No way is this "Major". Simply removing the checkbox completely takes care of the problem. And as you said, this is only a problem for the first launch.

Gene
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Launch from Windows installer fails to drop privileges

Post by Kunda1 »

Who wants to be assigned to this ticket? :D
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply