Example #1
0
/* ARGSUSED */
bool_t
rpcbproc_unset_com(rpcb *regp, bool_t *result, ar_svc_req_t *rqstp, 
		   arpcvers_t rpcbversnum)
{
	bool_t ans;
	char owner[64];

#ifdef RPCBIND_DEBUG
	if (debugging) {
		fprintf(stderr, "RPCB_UNSET request for (%lu, %lu, %s) : ",
			(unsigned long)regp->r_prog, 
			(unsigned long)regp->r_vers,
			regp->r_netid);
	}
#endif
	ans = map_unset(regp, getowner(rqstp->rq_xprt, owner, sizeof owner));
#ifdef RPCBIND_DEBUG
	if (debugging) {
		fprintf(stderr, "%s\n", ans == TRUE ? "succeeded" : "failed");
	}
#endif
	/* XXX: should have used some defined constant here */
	rpcbs_unset(rpcbversnum - 2, ans);
	*result = ans;
	return TRUE;
}
Example #2
0
xtrysend()
{
	int i;

	dem_open(dfname);		/*open spider connection.*/
	if((dfb = fopen(dfname, "r")) == NULL){
		if(LDIRNAM < (i = sizeof(baddf)-1)){
			strncpy(baddf, dfname, i);
			baddf[i] = '\0';
			baddf[LDIRNAM] = 'b';
			link(dfname, baddf);
		}
		unlink(dfname);
		retcode = 0;
		trouble("Can't read %s.", dfname);
	}
	getowner(dfname);		/*RBB*/
	mesp = message;
	*mesp = 0;
	while (getline()) switch (line[0]) {

	case 'S':
		get_snumb();		/*get snumb for GCOS.*/
		continue;

	case 'B':
		if(sascii(0))
			trouble("Can't send %s.", &line[1]);
		continue;

	case 'F':
		if(sascii(1))
			trouble("Can't send %s.", &line[1]);
		continue;

	case 'I':			/*mail back $IDENT card. MRW*/
		mesp = copline(&line[1], linel-1, mesp);

	case 'L':
		lwrite();		/*write a literal line.*/
		continue;

	case 'M':
		continue;

	case 'N':			/*mail back file name. MRW*/
		copline(&line[1], linel-1, mailfname);
		continue;

	case 'Q':			/*additional text to mail back*/
		if(mesp+linel <= message+MXMESS)
			mesp = copline(&line[1], linel-1, mesp);

	case 'U':
		continue;
	}
/*
 * Second pass.
 * Unlink files and send mail.
 */
	alarm(0);
	fseek(dfb, (long)0, 0);
	while (getline()) switch (line[0]) {

	default:
		continue;

	case 'U':
		unlink(&line[1]);
		continue;

	case 'M':
		sendmail();
		continue;
	}
	FCLOSE(dfb);
	dem_close();		/*close connection to spider.*/
	unlink(dfname);
	retcode = 0;
	trouble("OK: %-5s %-7s %-8s", snumb, fowner, dfname+LDIRNAM);	/*RBB*/
}
Example #3
0
/* TODO: does this work under cygwin? mkstemp() may or may not open
   the file using O_BINARY, and then we *do* upload it using O_BINARY,
   so maybe this will screw things up. Maybe we should fcntl it and
   set O_BINARY, if that is allowed under cygwin? */
void execute_edit(const char *remote)
{
    char *real_remote;
    unsigned int can_lock; /* can we LOCK it? */
    struct ne_lock *lock = NULL;
    char fname[PATH_MAX] = "/tmp/cadaver-edit-XXXXXX";
    const char *pnt;
    int fd;
    int is_checkout, is_checkin;
    
    real_remote = resolve_path(session.uri.path, remote, false);

    /* Don't let them edit a collection, since PUT to a collection is
     * bogus. Really we want to be able to fetch a "DefaultDocument"
     * property, and edit on that instead: IIS does expose such a
     * property. Would be a nice hack to add the support to mod_dav
     * too. */
    if (getrestype(real_remote) == resr_collection) {
	printf(_("You cannot edit a collection resource (%s).\n"),
	       real_remote);
	goto edit_bail;
    }

    can_lock = is_lockable(real_remote);

    /* Give the local temp file the same extension as the remote path,
     * so the editor can have a stab at the content-type. */
    pnt = strrchr(real_remote, '.');
    if (pnt != NULL && strchr(pnt, '/') == NULL) {
	strncat(fname, pnt, PATH_MAX);
	fname[PATH_MAX-1] = '\0';
    }

    fd = cad_mkstemp(fname);
    if (fd == -1) {
	printf(_("Could not create temporary file %s:\n%s\n"), fname,
	       strerror(errno));
	goto edit_bail;
    }

    /* Sanity check on the file perms. */
#ifdef HAVE_FCHMOD
    if (fchmod(fd, 0600) == -1) {
#else
    if (chmod(fname, 0600) == -1) {
#endif
	printf(_("Could not set file permissions for %s:\n%s\n"), fname,
	       strerror(errno));
	goto edit_bail;
    }
   
    if (can_lock) {
	lock = ne_lock_create();
	ne_fill_server_uri(session.sess, &lock->uri);
	lock->uri.path = ne_strdup(real_remote);
	lock->owner = getowner();
	out_start("Locking", remote);
	if (out_handle(ne_lock(session.sess, lock))) {
	    ne_lockstore_add(session.locks, lock);
	} else {
	    ne_lock_destroy(lock);
	    goto edit_close;
	}
    } else {
	/* TODO: HEAD and get the Etag/modtime */
    }

    /* Return 1: Checkin, 2: Checkout, 0: otherwise */
    is_checkin = is_vcr(real_remote);
    if (is_checkin==1) {
    	execute_checkout(real_remote);
    }
    
    output(o_download, _("Downloading `%s' to %s"), real_remote, fname);

    /* Don't puke if get fails -- perhaps we are creating a new one? */
    out_result(ne_get(session.sess, real_remote, fd));
    
    if (close(fd)) {
	output(o_finish, _("Error writing to temporary file: %s\n"), 
	       strerror(errno));
    } 
    else if (!run_editor(fname)) {
	int upload_okay = 0;

	fd = open(fname, O_RDONLY | OPEN_BINARY_FLAGS);
	if (fd < 0) {
	    output(o_finish, 
		   _("Could not re-open temporary file: %s\n"),
		   strerror(errno));
	} else {
	    do {
		output(o_upload, _("Uploading changes to `%s'"), real_remote);
		/* FIXME: conditional PUT using fetched Etag/modtime if
		 * !can_lock */
		if (out_handle(ne_put(session.sess, real_remote, fd))) {
		    upload_okay = 1;
		} else {
		    /* TODO: offer to save locally instead */
		    printf(_("Try uploading again (y/n)? "));
		    if (!yesno()) {
			upload_okay = 1;
		    }
		}
	    } while (!upload_okay);
	    close(fd);
	}
    }
    
    if (unlink(fname)) {
	printf(_("Could not delete temporary file %s:\n%s\n"), fname,
	       strerror(errno));
    }	       

    /* Return 1: Checkin, 2: Checkout, 0: otherwise */
    is_checkout = is_vcr(real_remote);
    if (is_checkout==2) {
    	execute_checkin(real_remote);
    }
    
    /* UNLOCK it again whether we succeed or failed in our mission */
    if (can_lock) {
	output(o_start, "Unlocking `%s':", remote);
	out_result(ne_unlock(session.sess, lock));
	ne_lockstore_remove(session.locks, lock);
	ne_lock_destroy(lock);
    }

    goto edit_bail;
edit_close:
    close(fd);
edit_bail:
    free(real_remote);
    return;
}