2000-03-15 11:21:53 +00:00
|
|
|
/* vi: ts=8 sts=4 sw=4
|
|
|
|
*
|
|
|
|
* This file is part of the KDE project, module kdesu.
|
|
|
|
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
|
2008-01-09 13:13:05 +00:00
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software
|
|
|
|
and its documentation for any purpose and without fee is hereby
|
|
|
|
granted, provided that the above copyright notice appear in all
|
|
|
|
copies and that both that the copyright notice and this
|
|
|
|
permission notice and warranty disclaimer appear in supporting
|
|
|
|
documentation, and that the name of the author not be used in
|
|
|
|
advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
The author disclaim all warranties with regard to this
|
|
|
|
software, including all implied warranties of merchantability
|
|
|
|
and fitness. In no event shall the author be liable for any
|
|
|
|
special, indirect or consequential damages or any damages
|
|
|
|
whatsoever resulting from loss of use, data or profits, whether
|
|
|
|
in an action of contract, negligence or other tortious action,
|
|
|
|
arising out of or in connection with the use or performance of
|
|
|
|
this software.
|
|
|
|
|
2000-03-15 11:21:53 +00:00
|
|
|
*/
|
|
|
|
|
2007-12-23 22:58:09 +00:00
|
|
|
#ifndef PASSWD_H
|
|
|
|
#define PASSWD_H
|
2000-03-15 11:21:53 +00:00
|
|
|
|
2007-05-09 22:23:52 +00:00
|
|
|
#include <QtCore/QByteRef>
|
2000-03-15 11:21:53 +00:00
|
|
|
#include <kdesu/process.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A C++ API to passwd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PasswdProcess
|
2007-10-02 12:12:47 +00:00
|
|
|
: public KDESu::PtyProcess
|
2000-03-15 11:21:53 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-06-23 18:53:52 +00:00
|
|
|
PasswdProcess(const QByteArray &user = QByteArray());
|
2000-03-15 11:21:53 +00:00
|
|
|
~PasswdProcess();
|
|
|
|
|
2000-07-05 17:28:14 +00:00
|
|
|
enum Errors { PasswdNotFound=1, PasswordIncorrect, PasswordNotGood };
|
|
|
|
|
2000-03-15 11:21:53 +00:00
|
|
|
int checkCurrent(const char *oldpass);
|
|
|
|
int exec(const char *oldpass, const char *newpass, int check=0);
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
QByteArray error() { return m_Error; }
|
2000-03-15 11:21:53 +00:00
|
|
|
|
|
|
|
private:
|
2007-06-23 18:53:52 +00:00
|
|
|
bool isPrompt(const QByteArray &line, const char *word=0L);
|
2000-03-15 11:21:53 +00:00
|
|
|
int ConversePasswd(const char *oldpass, const char *newpass,
|
2008-03-06 22:20:29 +00:00
|
|
|
int check);
|
2000-03-15 11:21:53 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
QByteArray m_User, m_Error;
|
2003-04-21 18:52:31 +00:00
|
|
|
bool bOtherUser;
|
2000-03-15 11:21:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-12-23 22:58:09 +00:00
|
|
|
#endif // PASSWD_H
|