Fossil

Check-in [55f3f3d4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:If the FOSSIL_PWREADER environment variable is set to the name of a program, then use that program to prompt and read passwords and passphrases from the user when required, in place of the getpass() library routine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 55f3f3d42d546182eea390ad0af7026a4739f996
User & Date: drh 2016-06-07 15:27:25
Context
2016-06-09
02:22
Use sqlite3_snprintf instead because it guarantees that the buffer will be zero-terminated and to avoid warnings on OpenBSD. check-in: 460b93b5 user: andybradford tags: trunk
2016-06-07
15:27
If the FOSSIL_PWREADER environment variable is set to the name of a program, then use that program to prompt and read passwords and passphrases from the user when required, in place of the getpass() library routine. check-in: 55f3f3d4 user: drh tags: trunk
01:26
Fix typo in test_markdown_render function name. (no functional change since the command name was okay). check-in: c94b49ad user: mgagnon tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/user.c.

87
88
89
90
91
92
93









94
95













96
97















98

99
100
101
102
103
104
105
  }
  pwd[i]='\0';
  fputs("\n", stderr);
  return pwd;
}
#endif










/*
** Do a single prompt for a passphrase.  Store the results in the blob.













*/
static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){















  char *z = getpass(zPrompt);

  strip_string(pPassphrase, z);
}

/*
** Prompt the user for a password.  Store the result in the pPassphrase
** blob.
**







>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  }
  pwd[i]='\0';
  fputs("\n", stderr);
  return pwd;
}
#endif

#if defined(_WIN32) || defined(WIN32)
# include <io.h>
# include <fcntl.h>
# undef popen
# define popen _popen
# undef pclose
# define pclose _pclose
#endif

/*
** Do a single prompt for a passphrase.  Store the results in the blob.
**
** If the FOSSIL_PWREADER environment variable is set, then it will
** be the name of a program that prompts the user for their password/
** passphrase in a secure manner.  The program should take one or more
** arguments which are the prompts and should output the acquired
** passphrase as a single line on stdout.  This function will read the
** output using popen().
**
** If FOSSIL_PWREADER is not set, or if it is not the name of an
** executable, then use the C-library getpass() routine.
**
** The return value is a pointer to a static buffer that is overwritten
** on subsequent calls to this same routine.
*/
static void prompt_for_passphrase(const char *zPrompt, Blob *pPassphrase){
  char *z;
  const char *zProg = fossil_getenv("FOSSIL_PWREADER");
  if( zProg && zProg[0] ){
    static char zPass[100];
    Blob cmd;
    FILE *in;
    blob_zero(&cmd);
    blob_appendf(&cmd, "%s \"Fossil Passphrase\" \"%s\"", zProg, zPrompt);
    zPass[0] = 0;
    in = popen(blob_str(&cmd), "r");
    fgets(zPass, sizeof(zPass), in);
    pclose(in);
    blob_reset(&cmd);
    z = zPass;
  }else{
    z = getpass(zPrompt);
  }
  strip_string(pPassphrase, z);
}

/*
** Prompt the user for a password.  Store the result in the pPassphrase
** blob.
**