#include "includes.h"
#include <signal.h>
#include <ctype.h>
int mysetuid(uid_t){return 0;}
int mysetgid(uid_t){return 0;}
int seteuid(uid_t){return 0;}
int setegid(uid_t){return 0;}
int initgroups(const char *, int){return 0;}
int setgroups(int, const gid_t *){return 0;}
void freerrset(struct rrsetinfo *){}
char *crypt(char *, char *){return NULL;}
int
getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **)
{
return ERRSET_FAIL;
}
void openlog(char *, int, int){}
void closelog(void){}
void
syslog(const char *fmt,...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
char *
readpassphrase(const char *prompt, char *buf, size_t nbuf, int flags)
{
char *p;
int c;
FILE *fi;
void (*sig)(int);
if ((!(flags&RPP_STDIN)) && (fi = fopen("/dev/cons", "r"))){
setbuf(fi, (char *)NULL);
if(!(flags & RPP_ECHO_ON))
tty_echooff(0); /* arg is ignored */
}else {
if (flags & RPP_REQUIRE_TTY) {
errno = ENOTTY;
return NULL;
}
fi = stdin;
}
sig = signal(SIGINT, SIG_IGN);
if(!(flags & RPP_STDIN))
fprintf(stderr, "%s", prompt); fflush(stderr);
for (p=buf; (c = getc(fi))!='\n' && c!='\r' && c!=EOF;) {
if (p < buf+nbuf-1) {
if (flags & RPP_SEVENBIT)
c &= 0xff;
if (isalpha(c)) {
if (flags & RPP_FORCELOWER)
c = tolower(c);
if (flags & RPP_FORCEUPPER)
c = toupper(c);
}
*p++ = c;
}
}
*p = '\0';
if (!(flags & RPP_STDIN))
fprintf(stderr, "\n"); fflush(stderr);
if (!(flags & RPP_ECHO_ON))
tty_echoon(0); /* arg is ignored */
signal(SIGINT, sig);
if (fi != stdin)
fclose(fi);
return buf;
}
|