KDESu

sshprocess.h
1 /*
2  This file is part of the KDE project, module kdesu.
3  SPDX-FileCopyrightText: 2000 Geert Jansen <[email protected]>
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 
15 namespace KDESu
16 {
17 class SshProcessPrivate;
18 
19 /** \class SshProcess sshprocess.h KDESu/SshProcess
20  * Executes a remote command, using ssh.
21  */
22 
23 class KDESU_EXPORT SshProcess : public StubProcess
24 {
25 public:
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 
68 protected:
69  void virtual_hook(int id, void *data) override;
70  QByteArray display() override;
71  QByteArray displayAuth() override;
72 
73 private:
74  int converseSsh(const char *password, int check);
75 
76 private:
77  Q_DECLARE_PRIVATE_D(PtyProcess::d, SshProcess)
78 #if KDESU_BUILD_DEPRECATED_SINCE(5, 79)
79  // Unused, kept for ABI compatibility
80  const void *__kdesu_d_do_not_use;
81 #endif
82 };
83 
84 }
85 
86 #endif // KDESUSSHPROCESS_H
void setHost(ScriptableExtension *host)
ScriptableExtension * host() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:48:58 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.