/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pg_config.h" #include "socket.h" #include #include #include #include /* * Open a file to a shell command. The command should have the * same uid/gid as the process writing onto the slave side. * Since we store the file's FILE structure pointer in a static * variable, there can't be more than one file open at the same * time. */ int connect_file(const char *address) { int fd; DBG(syslog(LOG_DEBUG, "opening file '%s'", address)); fd = open(address, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); if (fd == FAIL) { syslog(LOG_ERR, "open: %m"); return FAIL; } return fd; } result shutdown_file(int fd) { if (close(fd) == FAIL) { syslog(LOG_ERR, "close: %m"); return FAIL; } return SUCCESS; }