2000-03-15 11:21:53 +00:00
|
|
|
/* vi: ts=8 sts=4 sw=4
|
|
|
|
*
|
2000-07-05 17:28:14 +00:00
|
|
|
* $Id$
|
2000-03-15 11:21:53 +00:00
|
|
|
*
|
|
|
|
* This file is part of the KDE project, module kdesu.
|
|
|
|
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __Passwd_h_Included__
|
|
|
|
#define __Passwd_h_Included__
|
|
|
|
|
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
|
|
|
|
: public PtyProcess
|
|
|
|
{
|
|
|
|
public:
|
2005-07-28 14:59:42 +00:00
|
|
|
PasswdProcess(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:
|
2005-07-28 14:59:42 +00:00
|
|
|
bool isPrompt(QByteArray line, const char *word=0L);
|
2000-03-15 11:21:53 +00:00
|
|
|
int ConversePasswd(const char *oldpass, const char *newpass,
|
|
|
|
int check);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __Passwd_h_Included__
|