1 /***************************************************************************
2 * Copyright 2003 Braden MacDonald <bradenm_k@shaw.ca> *
3 * Copyright 2003 Ravikiran Rajagopal <ravi@ee.eng.ohio-state.edu> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License (version 2) as *
7 * published by the Free Software Foundation. *
9 ***************************************************************************/
12 * @file Change a user's 'finger' information, specifically their full name.
13 * derived from kdepasswd.
16 #include "chfnprocess.h"
21 #include <kdesu/process.h>
24 int ChfnProcess::exec(const char *pass
, const char *name
)
26 // Try to set the default locale to make the parsing of the output
28 putenv((char*)"LC_ALL=C");
30 QList
<QByteArray
> args
;
33 int ret
= KDESu::PtyProcess::exec("chfn", args
);
37 ret
= ConverseChfn(pass
);
46 * Return values: -1 = unknown error, 0 = ok, >0 = error code.
48 int ChfnProcess::ConverseChfn(const char *pass
)
58 continue;// discard line
59 else if ( line
.contains( "Permission denied" ) )
66 if ( line
.contains( "Password: " )/*isPrompt( line, "password" )*/ )
69 write(fd(), pass
, strlen(pass
));
73 line
= readLine(); // Let's see what the outcome was
75 if ( line
.contains( "Changing finger info" ) )
79 else if ( line
.contains( "information changed" ) )
84 else if ( line
.isEmpty() )
89 else if ( line
.contains( "Password error" ) || line
.contains("Incorrect password") )