~ubuntu-branches/ubuntu/utopic/synaptic/utopic

« back to all changes in this revision

Viewing changes to gtk/rgutils.cc

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Jonathan Dowland, Luke Drummond, Hans Joachim Desserud, Rafaël Carré, Igor Pashev, Michael Vogt
  • Date: 2014-03-18 21:02:46 UTC
  • Revision ID: package-import@ubuntu.com-20140318210246-de47w7z9ep0d3znm
Tags: 0.81
[ Jonathan Dowland ]
* Support parallel building.

[ Luke Drummond ]
* fix crash when no SUDO_USER is set (closes: #725885, #728714)

[ Hans Joachim Desserud ]
* lp:~hjd/synaptic/bug1242219: 
  fix "Untranslatable '_Contents' string in help menu (LP: #1242219)

[ Rafaël Carré ]
* po/fr.po:
  - fix typo in "%d packages will be upgraded\n" string

[ Igor Pashev ]
* portability fixes for rindex/bzero/fcntl (closes: #734473)
  to make it build on "dyson"

[ Michael Vogt ]
* replace rindex() with strrchr() (thanks to Igor Pashev for the
  suggestion)
* change refreshTable() code to avoid "jumping" around on the 
  screen when a package gets marked

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <cstdlib>
30
30
#include <cstring>
31
31
#include <pwd.h>
32
 
 
 
32
#include <assert.h>
33
33
#include <iostream>
34
34
 
35
35
#include "i18n.h"
138
138
       std::cerr << "Empty command for RunAsSudoUserCommand" << std::endl;
139
139
       return true;
140
140
    }
141
 
 
 
141
    bool getuidbyname = false;
142
142
    // try pkexec first, then sudo
143
143
    sudo_user = getenv("PKEXEC_UID");
 
144
    
144
145
    if (sudo_user == NULL) {
145
146
       sudo_user = getenv("SUDO_UID");
146
147
    }
147
 
    pwd = getpwuid(atoi(sudo_user));
 
148
    if (sudo_user == NULL) {
 
149
       sudo_user = getenv("USER");
 
150
       getuidbyname = true;
 
151
    }
 
152
    if (sudo_user == NULL) {
 
153
       return false;
 
154
    }
 
155
    if(strncmp("root", sudo_user, strlen("root")) == 0){
 
156
        return false;
 
157
    }
 
158
    if(!getuidbyname){
 
159
        pwd = getpwuid(atoi(sudo_user));
 
160
    }
 
161
    else{
 
162
         pwd = getpwnam(sudo_user);
 
163
    }
148
164
    sudo_user = pwd->pw_name;
149
165
#if 0 // does not work for some reason
150
166
    if(FileExists("/usr/bin/pkexec") && sudo_user != NULL)