Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / kdepasswd / passwd.h
blob29171c5f2ef15a6c5082db1c24e7599c55742903
1 /* vi: ts=8 sts=4 sw=4
3 * This file is part of the KDE project, module kdesu.
4 * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
6 Permission to use, copy, modify, and distribute this software
7 and its documentation for any purpose and without fee is hereby
8 granted, provided that the above copyright notice appear in all
9 copies and that both that the copyright notice and this
10 permission notice and warranty disclaimer appear in supporting
11 documentation, and that the name of the author not be used in
12 advertising or publicity pertaining to distribution of the
13 software without specific, written prior permission.
15 The author disclaim all warranties with regard to this
16 software, including all implied warranties of merchantability
17 and fitness. In no event shall the author be liable for any
18 special, indirect or consequential damages or any damages
19 whatsoever resulting from loss of use, data or profits, whether
20 in an action of contract, negligence or other tortious action,
21 arising out of or in connection with the use or performance of
22 this software.
26 #ifndef PASSWD_H
27 #define PASSWD_H
29 #include <QtCore/QByteRef>
30 #include <kdesu/process.h>
32 /**
33 * A C++ API to passwd.
36 class PasswdProcess
37 : public KDESu::PtyProcess
39 public:
40 PasswdProcess(const QByteArray &user = QByteArray());
41 ~PasswdProcess();
43 enum Errors { PasswdNotFound=1, PasswordIncorrect, PasswordNotGood };
45 int checkCurrent(const char *oldpass);
46 int exec(const char *oldpass, const char *newpass, int check=0);
48 QByteArray error() { return m_Error; }
50 private:
51 bool isPrompt(const QByteArray &line, const char *word=0L);
52 int ConversePasswd(const char *oldpass, const char *newpass,
53 int check);
55 QByteArray m_User, m_Error;
56 bool bOtherUser;
60 #endif // PASSWD_H