int rv;
rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
+ if (rv == -1) {
+ printf( "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ return 0;
+ }
+
rv = write(chkpwd_write_pipe[1], pass, 256);
+ if (rv == -1) {
+ printf( "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ return 0;
+ }
rv = read(chkpwd_read_pipe[0], buf, 4);
-
+ if (rv == -1) {
+ printf( "Communicatino with chkpwd broken: %s\n", strerror(errno));
+ return 0;
+ }
if (!strncmp(buf, "PASS", 4)) {
printf("pass\n");
return(1);
int main(void)
{
uid_t uid;
- size_t siz;
char buf[SIZ];
while (1) {
buf[0] = '\0';
- siz = read(0, &uid, sizeof(uid_t)); /* uid */
- siz = read(0, buf, 256); /* password */
+ read(0, &uid, sizeof(uid_t)); /* uid */
+ read(0, buf, 256); /* password */
if (buf[0] == '\0')
return (0);
static CtdlIPC *ipc = NULL;
-/*
- * make sure only one copy of sendcommand runs at a time, using lock files
- */
-int set_lockfile(void)
-{
- FILE *lfp;
- int onppid;
- int rv;
-
- if ((lfp = fopen(LOCKFILE, "r")) != NULL) {
- rv = fscanf(lfp, "%d", &onppid);
- fclose(lfp);
- if (!kill(onppid, 0) || errno == EPERM)
- return 1;
- }
- lfp = fopen(LOCKFILE, "w");
- fprintf(lfp, "%ld\n", (long) getpid());
- fclose(lfp);
- return (0);
-}
-
-void remove_lockfile(void)
-{
- unlink(LOCKFILE);
-}
-
/*
* Why both cleanup() and nq_cleanup() ? Notice the alarm() call in
* cleanup() . If for some reason sendcommand hangs waiting for the server
*/
void nq_cleanup(int e)
{
- remove_lockfile();
exit(e);
}