You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.8 KiB
80 lines
1.8 KiB
15 years ago
|
/* vi: ts=8 sts=4 sw=4
|
||
|
*
|
||
|
* $Id$
|
||
|
*
|
||
13 years ago
|
* This file is part of the KDE project, module tdesu.
|
||
15 years ago
|
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
|
||
|
*/
|
||
|
|
||
|
#include <config.h>
|
||
|
|
||
|
#include <kuniqueapplication.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
12 years ago
|
#include <tdeaboutdata.h>
|
||
|
#include <tdecmdlineargs.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
15 years ago
|
#include <kuser.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
#include "passwd.h"
|
||
|
#include "passwddlg.h"
|
||
|
|
||
12 years ago
|
static TDECmdLineOptions options[] =
|
||
15 years ago
|
{
|
||
|
{ "+[user]", I18N_NOOP("Change password of this user"), 0 },
|
||
12 years ago
|
TDECmdLineLastOption
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
int main(int argc, char **argv)
|
||
|
{
|
||
11 years ago
|
TDEAboutData aboutData("tdepasswd", I18N_NOOP("TDE passwd"),
|
||
15 years ago
|
VERSION, I18N_NOOP("Changes a UNIX password."),
|
||
12 years ago
|
TDEAboutData::License_Artistic, "Copyright (c) 2000 Geert Jansen");
|
||
15 years ago
|
aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"),
|
||
|
"jansen@kde.org", "http://www.stack.nl/~geertj/");
|
||
|
|
||
12 years ago
|
TDECmdLineArgs::init(argc, argv, &aboutData);
|
||
|
TDECmdLineArgs::addCmdLineOptions(options);
|
||
15 years ago
|
KUniqueApplication::addCmdLineOptions();
|
||
|
|
||
|
|
||
|
if (!KUniqueApplication::start()) {
|
||
11 years ago
|
kdDebug() << "tdepasswd is already running" << endl;
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
|
KUniqueApplication app;
|
||
|
|
||
|
KUser ku;
|
||
14 years ago
|
TQCString user;
|
||
15 years ago
|
bool bRoot = ku.isSuperUser();
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
|
||
|
if (args->count())
|
||
|
user = args->arg(0);
|
||
|
|
||
11 years ago
|
/* You must be able to run "tdepasswd loginName" */
|
||
15 years ago
|
if ( !user.isEmpty() && user!=KUser().loginName().utf8() && !bRoot)
|
||
|
{
|
||
|
KMessageBox::sorry(0, i18n("You need to be root to change the password of other users."));
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQCString oldpass;
|
||
15 years ago
|
if (!bRoot)
|
||
|
{
|
||
11 years ago
|
int result = TDEpasswd1Dialog::getPassword(oldpass);
|
||
|
if (result != TDEpasswd1Dialog::Accepted)
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
|
||
11 years ago
|
TDEpasswd2Dialog *dlg = new TDEpasswd2Dialog(oldpass, user);
|
||
15 years ago
|
|
||
|
|
||
|
dlg->exec();
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|