KDESu

sshprocess.h
1/*
2 This file is part of the KDE project, module kdesu.
3 SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-only
6*/
7
8#ifndef KDESUSSHPROCESS_H
9#define KDESUSSHPROCESS_H
10
11#include "stubprocess.h"
12
13#include <kdesu/kdesu_export.h>
14
15namespace KDESu
16{
17class SshProcessPrivate;
18
19/** \class SshProcess sshprocess.h KDESu/SshProcess
20 * Executes a remote command, using ssh.
21 */
22
23class KDESU_EXPORT SshProcess : public StubProcess
24{
25public:
26 enum Errors {
27 SshNotFound = 1,
28 SshNeedsPassword,
29 SshIncorrectPassword,
30 };
31
32 explicit SshProcess(const QByteArray &host = QByteArray(), const QByteArray &user = QByteArray(), const QByteArray &command = QByteArray());
33 ~SshProcess() override;
34
35 /**
36 * Sets the target host.
37 */
38 void setHost(const QByteArray &host);
39
40 /**
41 * Sets the location of the remote stub.
42 */
43 void setStub(const QByteArray &stub);
44
45 /**
46 * Checks if the current user\@host needs a password.
47 * @return The prompt for the password if a password is required. A null
48 * string otherwise.
49 *
50 * @todo The return doc is so obviously wrong that the C code needs to be checked.
51 */
52 int checkNeedPassword();
53
54 /**
55 * Checks if the stub is installed and if the password is correct.
56 * @return Zero if everything is correct, nonzero otherwise.
57 */
58 int checkInstall(const char *password);
59
60 /**
61 * Executes the command.
62 */
63 int exec(const char *password, int check = 0);
64
65 QByteArray prompt() const;
66 QByteArray error() const;
67
68protected:
69 void virtual_hook(int id, void *data) override;
70 QByteArray display() override;
71 QByteArray displayAuth() override;
72
73private:
74 KDESU_NO_EXPORT int converseSsh(const char *password, int check);
75
76private:
77 Q_DECLARE_PRIVATE(SshProcess)
78};
79
80}
81
82#endif // KDESUSSHPROCESS_H
Executes a remote command, using ssh.
Definition sshprocess.h:24
Chat with kdesu_stub.
Definition stubprocess.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:55 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.