author | mickeyl <mickeyl> | 2005-02-10 11:20:17 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-02-10 11:20:17 (UTC) |
commit | 8b48966b1e202a30b5be1069f357d5a4583b58be (patch) (unidiff) | |
tree | b2615eb8c2ad02f53fbec90709df5e35d0e7cea7 | |
parent | 134bba16e6b476406eed60cb9ff1ae596fac7732 (diff) | |
download | opie-8b48966b1e202a30b5be1069f357d5a4583b58be.zip opie-8b48966b1e202a30b5be1069f357d5a4583b58be.tar.gz opie-8b48966b1e202a30b5be1069f357d5a4583b58be.tar.bz2 |
autologin: remove processing of command line arguments in favour of deciding
based on an entry in the opie-login.conf file
-rw-r--r-- | core/opie-login/main.cpp | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 711bedc..554efd3 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp | |||
@@ -62,39 +62,20 @@ int login_main ( int argc, char **argv, pid_t ppid ); | |||
62 | void sigterm ( int sig ); | 62 | void sigterm ( int sig ); |
63 | void sigint ( int sig ); | 63 | void sigint ( int sig ); |
64 | void exit_closelog ( ); | 64 | void exit_closelog ( ); |
65 | 65 | ||
66 | static struct option long_options [] = { | ||
67 | { "autologin", 1, 0, 'a' }, | ||
68 | { 0, 0, 0, 0 } | ||
69 | }; | ||
70 | |||
71 | |||
72 | int main ( int argc, char **argv ) | 66 | int main ( int argc, char **argv ) |
73 | { | 67 | { |
74 | int userExited = 0; | 68 | int userExited = 0; |
75 | pid_t ppid = ::getpid ( ); | 69 | pid_t ppid = ::getpid ( ); |
76 | 70 | ||
77 | if ( ::geteuid ( ) != 0 ) { | 71 | if ( ::geteuid ( ) != 0 ) { |
78 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); | 72 | ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)\n", argv [0] ); |
79 | return 1; | 73 | return 1; |
80 | } | 74 | } |
81 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and | 75 | if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and |
82 | ::setuid ( 0 ); // messes up things like config files | 76 | ::setuid ( 0 ); // messes up things like config files |
83 | 77 | ||
84 | char *autolog = 0; | ||
85 | int c; | ||
86 | while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { | ||
87 | switch ( c ) { | ||
88 | case 'a': | ||
89 | autolog = optarg; | ||
90 | break; | ||
91 | default: | ||
92 | ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); | ||
93 | return 2; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | //struct rlimit rl; | 78 | //struct rlimit rl; |
98 | //::getrlimit ( RLIMIT_NOFILE, &rl ); | 79 | //::getrlimit ( RLIMIT_NOFILE, &rl ); |
99 | 80 | ||
100 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) | 81 | //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) |
@@ -108,8 +89,14 @@ int main ( int argc, char **argv ) | |||
108 | 89 | ||
109 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); | 90 | ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); |
110 | ::atexit ( exit_closelog ); | 91 | ::atexit ( exit_closelog ); |
111 | 92 | ||
93 | const char* autolog = 0; | ||
94 | Config c( "opie-login" ); | ||
95 | c.setGroup( "autologin" ); | ||
96 | QString entry = c.readEntry( "user", "" ); | ||
97 | if ( !entry.isEmpty() ) autolog = ::strdup( (const char*) entry ); | ||
98 | |||
112 | while ( true ) { | 99 | while ( true ) { |
113 | pid_t child = ::fork ( ); | 100 | pid_t child = ::fork ( ); |
114 | 101 | ||
115 | if ( child < 0 ) { | 102 | if ( child < 0 ) { |
@@ -193,9 +180,9 @@ int main ( int argc, char **argv ) | |||
193 | 180 | ||
194 | QWSServer::setDesktopBackground( QImage() ); | 181 | QWSServer::setDesktopBackground( QImage() ); |
195 | ODevice::inst()->setDisplayStatus( true ); | 182 | ODevice::inst()->setDisplayStatus( true ); |
196 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); | 183 | LoginApplication *app = new LoginApplication ( argc, argv, ppid ); |
197 | LoginApplication::setLoginAs ( autolog ); | 184 | LoginApplication::setLoginAs( autolog ); |
198 | 185 | ||
199 | 186 | ||
200 | if ( LoginApplication::changeIdentity ( )) | 187 | if ( LoginApplication::changeIdentity ( )) |
201 | ::exit ( LoginApplication::login ( )); | 188 | ::exit ( LoginApplication::login ( )); |