summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/loginapplication.cpp5
-rw-r--r--core/opie-login/loginapplication.h5
-rw-r--r--core/opie-login/main.cpp11
3 files changed, 14 insertions, 7 deletions
diff --git a/core/opie-login/loginapplication.cpp b/core/opie-login/loginapplication.cpp
index 103d63b..8d86a71 100644
--- a/core/opie-login/loginapplication.cpp
+++ b/core/opie-login/loginapplication.cpp
@@ -23,52 +23,53 @@
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#ifdef USEPAM
extern "C" {
#include <security/pam_appl.h>
}
#else
#include <crypt.h>
#include <shadow.h>
#endif
#include "loginapplication.h"
LoginApplication *lApp;
-LoginApplication::LoginApplication ( int &argc, char **argv )
+LoginApplication::LoginApplication ( int &argc, char **argv, pid_t parentpid )
: QPEApplication ( argc, argv, GuiServer )
{
lApp = this;
+ m_parentpid = parentpid;
}
const char *LoginApplication::s_username = 0;
#ifdef USEPAM
const char *LoginApplication::s_pam_password = 0;
int LoginApplication::pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * )
{
int replies = 0;
struct pam_response *reply = 0;
int size = sizeof( struct pam_response );
for ( int i = 0; i < num_msg; i++ ) {
switch ( msg [i]-> msg_style ) {
case PAM_PROMPT_ECHO_ON: // user name given to PAM already
return PAM_CONV_ERR;
case PAM_PROMPT_ECHO_OFF: // wants password
reply = (struct pam_response *) ::realloc ( reply, size );
if ( !reply )
return PAM_CONV_ERR;
size += sizeof( struct pam_response );
@@ -195,26 +196,26 @@ const char *LoginApplication::loginAs ( )
void LoginApplication::setLoginAs ( const char *name )
{
s_username = name;
}
QStringList LoginApplication::allUsers ( )
{
struct passwd *pwd;
QStringList sl;
while (( pwd = ::getpwent ( ))) {
if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 ))
sl << QString ( pwd-> pw_name );
}
::endpwent ( );
return sl;
}
void LoginApplication::quitToConsole ( )
{
QPEApplication::quit ( );
- ::kill ( ::getppid ( ), SIGTERM );
+ ::kill ( m_parentpid, SIGTERM );
}
diff --git a/core/opie-login/loginapplication.h b/core/opie-login/loginapplication.h
index 062c088..4e7cf79 100644
--- a/core/opie-login/loginapplication.h
+++ b/core/opie-login/loginapplication.h
@@ -18,50 +18,53 @@
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __OPIE_LOGINAPPLICATION_H__
#define __OPIE_LOGINAPPLICATION_H__
#include <qstringlist.h>
#include <qpe/qpeapplication.h>
#ifdef USEPAM
struct pam_message;
struct pam_response;
#endif
class LoginApplication : public QPEApplication {
public:
- LoginApplication ( int &argc, char **argv );
+ LoginApplication ( int &argc, char **argv, pid_t parentpid );
static bool checkPassword ( const char *user, const char *password );
static const char *loginAs ( );
static void setLoginAs ( const char *user );
static bool changeIdentity ( );
static bool login ( );
static QStringList allUsers ( );
void quitToConsole ( );
private:
static const char *s_username;
#ifdef USEPAM
static int pam_helper ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void * );
static const char *s_pam_password;
#endif
+
+private:
+ pid_t m_parentpid;
};
extern LoginApplication *lApp;
#endif
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 579a93a..674829d 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -39,60 +39,63 @@
#include <signal.h>
#include <getopt.h>
#include <string.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpestyle.h>
#include <qpe/power.h>
#include <qpe/config.h>
#include <opie/odevice.h>
#include <qwindowsystem_qws.h>
#include <qmessagebox.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qfile.h>
#include "loginapplication.h"
#include "loginwindowimpl.h"
#include "calibrate.h"
using namespace Opie;
-int login_main ( int argc, char **argv );
+int login_main ( int argc, char **argv, pid_t ppid );
void sigterm ( int sig );
void exit_closelog ( );
static struct option long_options [] = {
{ "autologin", 1, 0, 'a' },
{ 0, 0, 0, 0 }
};
int main ( int argc, char **argv )
{
+ pid_t ppid = ::getpid ( );
+
+
if ( ::geteuid ( ) != 0 ) {
::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
return 1;
}
if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
::setuid ( 0 ); // messes up things like config files
char *autolog = 0;
int c;
while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
switch ( c ) {
case 'a':
autolog = optarg;
break;
default:
::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
return 2;
}
}
// struct rlimit rl;
// ::getrlimit ( RLIMIT_NOFILE, &rl );
// for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
@@ -162,49 +165,49 @@ int main ( int argc, char **argv )
app-> exec ( );
delete app;
qApp = 0;
}
}
else {
if ( !autolog ) {
Config cfg ( "opie-login" );
cfg. setGroup ( "General" );
QString user = cfg. readEntry ( "AutoLogin" );
if ( !user. isEmpty ( ))
autolog = ::strdup ( user. latin1 ( ));
}
if ( autolog ) {
LoginApplication::setLoginAs ( autolog );
if ( LoginApplication::changeIdentity ( ))
::exit ( LoginApplication::login ( ));
else
::exit ( 0 );
}
else
- ::exit ( login_main ( argc, argv ));
+ ::exit ( login_main ( argc, argv, ppid ));
}
}
return 0;
}
void sigterm ( int /*sig*/ )
{
::exit ( 0 );
}
void exit_closelog ( )
{
::closelog ( );
}
class LoginScreenSaver : public QWSScreenSaver
{
public:
LoginScreenSaver ( )
{
m_lcd_status = true;
@@ -281,52 +284,52 @@ public:
if ( bright == -2 ) {
// Toggle between off and on
bright = m_backlight_bright ? 0 : -1;
m_backlight_forcedoff = !bright;
}
m_backlight_bright = bright;
bright = backlight ( );
ODevice::inst ( ) -> setDisplayBrightness ( bright );
m_backlight_bright = bright;
}
private:
bool m_lcd_status;
int m_backlight_bright;
bool m_backlight_forcedoff;
};
-int login_main ( int argc, char **argv )
+int login_main ( int argc, char **argv, pid_t ppid )
{
QWSServer::setDesktopBackground( QImage() );
- LoginApplication *app = new LoginApplication ( argc, argv );
+ LoginApplication *app = new LoginApplication ( argc, argv, ppid );
app-> setFont ( QFont ( "Helvetica", 10 ));
app-> setStyle ( new QPEStyle ( ));
ODevice::inst ( )-> setSoftSuspend ( true );
#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
if ( !QFile::exists ( "/etc/pointercal" )) {
// Make sure calibration widget starts on top.
Calibrate *cal = new Calibrate;
cal-> exec ( );
delete cal;
}
#endif
LoginScreenSaver *saver = new LoginScreenSaver;
saver-> setIntervals ( );
QWSServer::setScreenSaver ( saver );
saver-> restore ( );
LoginWindowImpl *lw = new LoginWindowImpl ( );
app-> setMainWidget ( lw );