KDESu 5.99.0
Public Types | Public Member Functions | Protected Member Functions | List of all members
KDESu::SshProcess

Executes a remote command, using ssh. More...

#include <KDESu/SshProcess>

Public Types

enum  Errors { SshNotFound = 1 , SshNeedsPassword , SshIncorrectPassword }
 
- Public Types inherited from KDESu::StubProcess
enum  Scheduler { SchedNormal , SchedRealtime }
 Different schedulers. More...
 
- Public Types inherited from KDESu::PtyProcess
enum  checkPidStatus { Error = -1 , NotExited = -2 , Killed = -3 }
 Error return values for checkPidExited() More...
 

Public Member Functions

 SshProcess (const QByteArray &host=QByteArray(), const QByteArray &user=QByteArray(), const QByteArray &command=QByteArray())
 
int checkInstall (const char *password)
 Checks if the stub is installed and if the password is correct. More...
 
int checkNeedPassword ()
 Checks if the current user@host needs a password. More...
 
QByteArray error () const
 
int exec (const char *password, int check=0)
 Executes the command. More...
 
QByteArray prompt () const
 
void setHost (const QByteArray &host)
 Sets the target host. More...
 
void setStub (const QByteArray &stub)
 Sets the location of the remote stub. More...
 
- Public Member Functions inherited from KDESu::StubProcess
void setCommand (const QByteArray &command)
 Set the command. More...
 
void setPriority (int prio)
 Set the priority of the process. More...
 
void setScheduler (int sched)
 Set the scheduler type. More...
 
void setUser (const QByteArray &user)
 Set the target user. More...
 
void setXOnly (bool xonly)
 Set to "X only mode": Sycoca is not built and kdeinit is not launched. More...
 
- Public Member Functions inherited from KDESu::PtyProcess
int enableLocalEcho (bool enable=true)
 Enables/disables local echo on the pseudo tty. More...
 
int exec (const QByteArray &command, const QList< QByteArray > &args)
 Forks off and execute a command. More...
 
int fd () const
 Returns the filedescriptor of the process. More...
 
int pid () const
 Returns the pid of the process. More...
 
QByteArray readAll (bool block=true)
 Read all available output from the program's standard out. More...
 
QByteArray readLine (bool block=true)
 Reads a line from the program's standard out. More...
 
void setEnvironment (const QList< QByteArray > &env)
 Set additinal environment variables. More...
 
void setErase (bool erase)
 Overwrites the password as soon as it is used. More...
 
void setExitString (const QByteArray &exit)
 Sets the exit string. More...
 
void setTerminal (bool terminal)
 Enables/disables terminal output. More...
 
void unreadLine (const QByteArray &line, bool addNewline=true)
 Puts back a line of input. More...
 
int waitForChild ()
 Waits for the child to exit. More...
 
int waitSlave ()
 Waits until the pty has cleared the ECHO flag. More...
 
int WaitSlave ()
 
void writeLine (const QByteArray &line, bool addNewline=true)
 Writes a line of text to the program's standard in. More...
 

Protected Member Functions

QByteArray display () override
 This virtual function can be overloaded when special behavior is desired. More...
 
QByteArray displayAuth () override
 See display. More...
 
void virtual_hook (int id, void *data) override
 Standard hack to add virtual methods in a BC way. More...
 
- Protected Member Functions inherited from KDESu::StubProcess
 StubProcess (StubProcessPrivate &dd)
 
int converseStub (int check)
 Exchange all parameters with kdesu_stub. More...
 
virtual QByteArray display ()
 This virtual function can be overloaded when special behavior is desired. More...
 
virtual QByteArray displayAuth ()
 See display. More...
 
void virtual_hook (int id, void *data) override
 Standard hack to add virtual methods in a BC way. More...
 
- Protected Member Functions inherited from KDESu::PtyProcess
 PtyProcess (PtyProcessPrivate &dd)
 
QList< QByteArray > environment () const
 
virtual void virtual_hook (int id, void *data)
 Standard hack to add virtual methods in a BC way. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from KDESu::PtyProcess
static bool checkPid (pid_t pid)
 Basic check for the existence of pid. More...
 
static int checkPidExited (pid_t pid)
 Check process exit status for process pid. More...
 
static int waitMS (int fd, int ms)
 Wait ms milliseconds (ie. More...
 
- Protected Attributes inherited from KDESu::StubProcess
QByteArray m_command
 
KDESuPrivate::KCookie * m_cookie
 
int m_priority
 
int m_scheduler
 
QByteArray m_user
 
bool m_XOnly
 
- Protected Attributes inherited from KDESu::PtyProcess
QByteArray m_command
 Unused. More...
 
bool m_erase
 
QByteArray m_exitString
 String to scan for in output that indicates child has exited. More...
 
int m_pid
 PID of child process. More...
 
bool m_terminal
 Indicates running in a terminal, causes additional newlines to be printed after output. More...
 

Detailed Description

Executes a remote command, using ssh.

Member Function Documentation

◆ checkInstall()

int KDESu::SshProcess::checkInstall ( const char *  password)

Checks if the stub is installed and if the password is correct.

Returns
Zero if everything is correct, nonzero otherwise.

◆ checkNeedPassword()

int KDESu::SshProcess::checkNeedPassword ( )

Checks if the current user@host needs a password.

Returns
The prompt for the password if a password is required. A null string otherwise.

◆ display()

QByteArray KDESu::SshProcess::display ( )
overrideprotectedvirtual

This virtual function can be overloaded when special behavior is desired.

By default, it returns the value returned by KCookie.

Reimplemented from KDESu::StubProcess.

◆ displayAuth()

QByteArray KDESu::SshProcess::displayAuth ( )
overrideprotectedvirtual

See display.

Reimplemented from KDESu::StubProcess.

◆ exec()

int KDESu::SshProcess::exec ( const char *  password,
int  check = 0 
)

Executes the command.

◆ setHost()

void KDESu::SshProcess::setHost ( const QByteArray &  host)

Sets the target host.

◆ setStub()

void KDESu::SshProcess::setStub ( const QByteArray &  stub)

Sets the location of the remote stub.

◆ virtual_hook()

void KDESu::SshProcess::virtual_hook ( int  id,
void *  data 
)
overrideprotectedvirtual

Standard hack to add virtual methods in a BC way.

Unused.

Reimplemented from KDESu::PtyProcess.