summaryrefslogtreecommitdiffstats
path: root/libkpgp/kpgpbase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libkpgp/kpgpbase.cpp')
-rw-r--r--libkpgp/kpgpbase.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/libkpgp/kpgpbase.cpp b/libkpgp/kpgpbase.cpp
index c8efdfa4a..5b28bd540 100644
--- a/libkpgp/kpgpbase.cpp
+++ b/libkpgp/kpgpbase.cpp
@@ -59,7 +59,7 @@ Base::clear()
int
-Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
+Base::run( const char *cmd, const TQString& passphrase, bool onlyReadFromPGP )
{
/* the pipe ppass is used for to pass the password to
* pgp. passing the password together with the normal input through
@@ -74,7 +74,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
struct pollfd pollin, pollout, pollerr;
int pollstatus;
- if(passphrase)
+ if (!passphrase.isNull())
{
if (pipe(ppass) < 0) {
// An error occurred
@@ -83,7 +83,8 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
}
pass = fdopen(ppass[1], "w");
- fwrite(passphrase, sizeof(char), strlen(passphrase), pass);
+ TQCString pass2 = passphrase.local8Bit();
+ fwrite(pass2, sizeof(char), pass2.length(), pass);
fwrite("\n", sizeof(char), 1, pass);
fclose(pass);
close(ppass[1]);
@@ -368,7 +369,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
close(perr[0]);
unsetenv("PGPPASSFD");
- if(passphrase)
+ if (!passphrase.isNull())
close(ppass[0]);
// Did the child exit normally?
@@ -397,7 +398,7 @@ Base::run( const char *cmd, const char *passphrase, bool onlyReadFromPGP )
int
-Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
+Base::runGpg( const char *cmd, const TQString& passphrase, bool onlyReadFromGnuPG )
{
/* the pipe ppass is used for to pass the password to
* pgp. passing the password together with the normal input through
@@ -417,7 +418,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
const int STD_IN = 2;
int pollstatus;
- if(passphrase)
+ if (!passphrase.isNull())
{
if (pipe(ppass) < 0) {
// An error occurred
@@ -426,7 +427,8 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
}
pass = fdopen(ppass[1], "w");
- fwrite(passphrase, sizeof(char), strlen(passphrase), pass);
+ TQCString pass2 = passphrase.local8Bit();
+ fwrite(pass2, sizeof(char), pass2.length(), pass);
fwrite("\n", sizeof(char), 1, pass);
fclose(pass);
close(ppass[1]);
@@ -459,7 +461,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
printf("Something went wrong in libkpgp/kpgpbase.cpp\n");
}
- if( passphrase ) {
+ if (!passphrase.isNull()) {
if( mVersion >= "1.0.7" ) {
// GnuPG >= 1.0.7 supports the gpg-agent, so we look for it.
if( 0 == getenv("GPG_AGENT_INFO") ) {
@@ -504,7 +506,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
//#warning FIXME: there has to be a better way to do this
/* this is nasty nasty nasty (but it works) */
- if( passphrase ) {
+ if (!passphrase.isNull()) {
if( mVersion >= "1.0.7" ) {
// GnuPG >= 1.0.7 supports the gpg-agent, so we look for it.
if( 0 == getenv("GPG_AGENT_INFO") ) {
@@ -682,7 +684,7 @@ Base::runGpg( const char *cmd, const char *passphrase, bool onlyReadFromGnuPG )
close(pout[0]);
close(perr[0]);
- if(passphrase)
+ if (!passphrase.isNull())
close(ppass[0]);
// Did the child exit normally?