Results 1 to 10 of 36

Thread: Howto: Install Wine applications for Multiple Users

Threaded View

  1. #1
    Join Date
    Feb 2005
    Beans
    102

    Howto: Install Wine applications for Multiple Users

    Background:
    Some proprietary windows programs only allow a limited number of installations, making it desirable to install to a common location in the “windows style”, instead of installing separately for each user in the “wine style”. In addition, it may be more efficient for an administrator to install a program once, even if the license allows for unlimited installations. Codeweavers refers to this type of multi-user installation as Shared Global Mode.

    Outline of method:
    We are going to create a new user, “windows”, that will host the system-wide wine installation. We will then give some of our users permission to run windows programs as the user windows, with wine, on their own desktop, without having to switch accounts or enter passwords.

    Estimated time
    15-20 minutes

    Preparation:
    Install wine if you haven't already done so.
    Code:
    sudo apt-get install wine
    Run winecfg to test your installation
    Code:
    winecfg
    You should see a window pop up with multiple tabs. Applications, Drives, Graphics, Audio, etc.
    Close the window

    STEP 1. Add a new user without a password.
    Pick a user name that doesn't exist on your system
    Code:
    sudo adduser --disabled-password windows
    Just hit enter to accept defaults for name, office, phone etc., then answer Y.

    STEP 2. Backup /etc/sudoers and use visudo to edit /etc/sudoers

    2.1 Backup /etc/sudoers in case something bad happens.
    Code:
    sudo cp /etc/sudoers /etc/sudoers.bak
    2.2 Edit /etc/sudoers, but only with visudo.
    Code:
    sudo visudo
    Pay careful attention to syntax here. This file isn't very forgiving to editing mistakes.
    I used this page to figure out how to edit with vi. I got a log of mileage out of i, o, x, dd and :wq.

    If you're a nano user, you can do this:
    Code:
    sudo EDITOR=nano visudo
    If you want something more graphical, you can use xedit:
    Code:
    sudo EDITOR=xedit visudo
    2.3 In the User alias section, define which users will administrate the computer. (Have root privileges)
    This will probably be all the people currently in your admin group
    Code:
    User_Alias ADMIN = ron
    2.4 In the User alias section, define which users can run the wine/windows programs.

    Code:
    User_Alias WINDOWS_USERS = kim,ian,mason,collin,ron
    * no spaces between the names

    2.5 In the command alias section, define which programs the windows user can run
    Code:
    Cmnd_Alias WINDOWS = /usr/bin/wine,/usr/bin/winecfg
    2.6 In the defaults section, add the following commands so that we will be able to use our current X windows display
    Code:
    Defaults:WINDOWS_USERS env_reset
    Defaults:WINDOWS_USERS env_keep += DISPLAY
    Defaults:WINDOWS_USERS env_keep += XAUTHORITY
    2.7 Change the line that defines who gets admin privileges
    Delete this:
    Code:
    %admin ALL=(ALL) ALL
    This gave admin privileges to anybody in the admin group defined in /etc/group

    Replace it with this:
    Code:
    ADMIN ALL=(ALL) ALL
    This gives admin privileges to anybody listed in the ADMIN alias defined in step 2.3. The difference is subtle but important. Without this change the people in the admin group will always have to supply their password before they can run windows programs.

    2.8 Add a line at the bottom that gives WINDOWS_USERS permission to run WINDOWS programs, without a password, as user windows
    Code:
    WINDOWS_USERS ALL = (windows) NOPASSWD: WINDOWS
    Here is what my /etc/sudoers file looks like after making these changes:
    Code:
    # User alias specification
    
    # define which users can run the wine/windows programs
    User_Alias WINDOWS_USERS = kim,ian,mason,collin,ron
    
    # define which users can administrate (become root)
    User_Alias ADMIN = ron
    
    # Cmnd alias specification
    
    # define which commands the WINDOWS_USERS may run
    Cmnd_Alias WINDOWS = /usr/bin/wine,/usr/bin/winecfg
    
    # Defaults
    Defaults:WINDOWS_USERS env_reset
    Defaults:WINDOWS_USERS env_keep += DISPLAY
    Defaults:WINDOWS_USERS env_keep += XAUTHORITY
    Defaults	!lecture,tty_tickets,!fqdn
    
    # User privilege specification
    root	ALL=(ALL) ALL
    
    # Members of the admin user_alias, defined above, may gain root privileges
    ADMIN ALL=(ALL) ALL
    
    # The WINDOWS_USERS may run WINDOWS programs as user windows without a password
    WINDOWS_USERS ALL = (windows) NOPASSWD: WINDOWS
    There's really not much too it without the comments

    STEP 3: Move your .wine directory over to the windows user's .wine directory
    Code:
    sudo mv ~ron/.wine ~windows/.wine -iv
    sudo chown windows:users ~windows/.wine/ -Rfv
    STEP 4: Let the windows user have access to your display
    This command has to be issued from the user shell (not root)
    Code:
    xhost +local:windows
    Issuing this command will only work until you log out. To make things permanent, add the command to System>Preferences>Sessions>Startup Programs in the desktop of each of the Windows_Users

    STEP 5: Run your windows programs with sudo, no password required.
    Code:
    sudo -u windows -H wine notepad
    You can use variations of this command in your graphical menus for any wine program that you want to run from the system wine. You will have to edit the menus of each indivial windows_user for any system wine programs that you want them to be able to run.
    If you want to run or install programs for yourself (not for all the windows_users) just use wine without sudo like this:
    Code:
    wine notepad
    What should I do if things go horribly wrong?
    Code:
    sudo mv ~windows/.wine ~ron/.wine -iv
    sudo chown ron:ron ~ron/.wine/ -Rfv
    sudo deluser --remove-home --backup windows
    sudo cp /etc/sudoers.bak /etc/sudoers
    Remove the xhost +local:windows from your startup programs if you put it there.
    Remove the sudo -u windows -H from any menu items that you edited

    This moves your wine directory back, puts the file ownership back in your name, completely removes the new user and replaces your sudoers file. Remember that you can even replace the sudoers file from a live disk if things go horribly wrong and you can't log in or get root privileges.

    Broader applications
    After looking at the above information, it should be a simple exercise to modify my steps to run any program, including a browser like firefox, as a different user on your desktop.

    Closing Thoughts
    a. Remember to add the windows user to the appropriate groups so that wine can access the necessary system resources: cdroms, sound, floppies etc.
    b. Remember that if you want to add a new system administrator that you not only have to add them to the admin group, you will have to edit /etc/sudoers to add them to the ADMIN user alias.

    Test Systems
    Ubuntu Hardy 8.04 on Dell Inspiron 5100
    Ubuntu64 Hardy 8.04 on a homebuilt quadcore
    Ubuntu Intrepid 8.10 circa 9/11/08 on a homebuilt quadcore (I got nano as the editor for visudo instead of vi)
    Ubuntu Jaunty 9.04

    Credits
    Link:Running Firefox as another user, using sudo
    Link:Running firefox as a different user Thanks Gaten for post #5
    Link:suauth and pam.d Thanks HalPomeranz for post #16

    Disclaimer
    As always, this worked for me, but YMMV. Read, think and remember that I am "just some guy on the internet" before you apply changes to an important system.
    Last edited by rsay; September 5th, 2009 at 09:42 AM. Reason: Added test on Jaunty

Tags for this Thread

Bookmarks

Posting Permissions

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