summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-10-30 04:54:19 +0100
committerLennart Poettering <lennart@poettering.net>2009-10-30 04:54:19 +0100
commit168be3830ae291dd819abebec813f76151487bb3 (patch)
tree783df8db52cac54b74d8e304d98e7ab5e4683bd8
parent88b72958bebd1770e45a4af2dc9fec75aaf1f2de (diff)
downloadpulseaudio-168be3830ae291dd819abebec813f76151487bb3.tar.gz
use pa_fopen_cloexec() where applicable
-rw-r--r--src/daemon/daemon-conf.c4
-rw-r--r--src/modules/module-cli.c2
-rw-r--r--src/modules/module-default-device-restore.c8
-rw-r--r--src/modules/module-detect.c8
-rw-r--r--src/modules/module-match.c2
-rw-r--r--src/modules/module-udev-detect.c2
-rw-r--r--src/modules/oss/oss-util.c6
-rw-r--r--src/pulse/client-conf.c2
-rw-r--r--src/pulsecore/cli-command.c2
-rw-r--r--src/pulsecore/conf-parser.c2
-rw-r--r--src/pulsecore/core-util.c8
-rw-r--r--src/pulsecore/database-simple.c4
-rw-r--r--src/pulsecore/pid.c2
-rw-r--r--src/pulsecore/sample-util.c2
14 files changed, 27 insertions, 27 deletions
diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 571faae45..bfd5c118d 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -577,7 +577,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
c->config_file = NULL;
f = filename ?
- fopen(c->config_file = pa_xstrdup(filename), "r") :
+ pa_fopen_cloexec(c->config_file = pa_xstrdup(filename), "r") :
pa_open_config_file(DEFAULT_CONFIG_FILE, DEFAULT_CONFIG_FILE_USER, ENV_CONFIG_FILE, &c->config_file);
if (!f && errno != ENOENT) {
@@ -652,7 +652,7 @@ FILE *pa_daemon_conf_open_default_script_file(pa_daemon_conf *c) {
else
f = pa_open_config_file(DEFAULT_SCRIPT_FILE, DEFAULT_SCRIPT_FILE_USER, ENV_SCRIPT_FILE, &c->default_script_file);
} else
- f = fopen(c->default_script_file, "r");
+ f = pa_fopen_cloexec(c->default_script_file, "r");
return f;
}
diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c
index 6bd0f4fc8..c5ff45646 100644
--- a/src/modules/module-cli.c
+++ b/src/modules/module-cli.c
@@ -105,7 +105,7 @@ int pa__init(pa_module*m) {
* of log messages, particularly because if stdout and stderr are
* dup'ed they share the same O_NDELAY, too. */
- if ((fd = open("/dev/tty", O_RDWR|O_CLOEXEC|O_NONBLOCK)) >= 0) {
+ if ((fd = pa_open_cloexec("/dev/tty", O_RDWR|O_NONBLOCK, 0)) >= 0) {
io = pa_iochannel_new(m->core->mainloop, fd, fd);
pa_log_debug("Managed to open /dev/tty.");
} else {
diff --git a/src/modules/module-default-device-restore.c b/src/modules/module-default-device-restore.c
index 27ae60e53..94f589e90 100644
--- a/src/modules/module-default-device-restore.c
+++ b/src/modules/module-default-device-restore.c
@@ -60,7 +60,7 @@ static void load(struct userdata *u) {
if (u->core->default_sink)
pa_log_info("Manually configured default sink, not overwriting.");
- else if ((f = fopen(u->sink_filename, "r"))) {
+ else if ((f = pa_fopen_cloexec(u->sink_filename, "r"))) {
char ln[256] = "";
pa_sink *s;
@@ -81,7 +81,7 @@ static void load(struct userdata *u) {
if (u->core->default_source)
pa_log_info("Manually configured default source, not overwriting.");
- else if ((f = fopen(u->source_filename, "r"))) {
+ else if ((f = pa_fopen_cloexec(u->source_filename, "r"))) {
char ln[256] = "";
pa_source *s;
@@ -108,7 +108,7 @@ static void save(struct userdata *u) {
return;
if (u->sink_filename) {
- if ((f = fopen(u->sink_filename, "w"))) {
+ if ((f = pa_fopen_cloexec(u->sink_filename, "w"))) {
pa_sink *s = pa_namereg_get_default_sink(u->core);
fprintf(f, "%s\n", s ? s->name : "");
fclose(f);
@@ -117,7 +117,7 @@ static void save(struct userdata *u) {
}
if (u->source_filename) {
- if ((f = fopen(u->source_filename, "w"))) {
+ if ((f = pa_fopen_cloexec(u->source_filename, "w"))) {
pa_source *s = pa_namereg_get_default_source(u->core);
fprintf(f, "%s\n", s ? s->name : "");
fclose(f);
diff --git a/src/modules/module-detect.c b/src/modules/module-detect.c
index b1f24e158..1fe8eb8b6 100644
--- a/src/modules/module-detect.c
+++ b/src/modules/module-detect.c
@@ -63,7 +63,7 @@ static int detect_alsa(pa_core *c, int just_one) {
FILE *f;
int n = 0, n_sink = 0, n_source = 0;
- if (!(f = fopen("/proc/asound/devices", "r"))) {
+ if (!(f = pa_fopen_cloexec("/proc/asound/devices", "r"))) {
if (errno != ENOENT)
pa_log_error("open(\"/proc/asound/devices\") failed: %s", pa_cstrerror(errno));
@@ -124,9 +124,9 @@ static int detect_oss(pa_core *c, int just_one) {
FILE *f;
int n = 0, b = 0;
- if (!(f = fopen("/dev/sndstat", "r")) &&
- !(f = fopen("/proc/sndstat", "r")) &&
- !(f = fopen("/proc/asound/oss/sndstat", "r"))) {
+ if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) &&
+ !(f = pa_fopen_cloexec("/proc/sndstat", "r")) &&
+ !(f = pa_fopen_cloexec("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
pa_log_error("failed to open OSS sndstat device: %s", pa_cstrerror(errno));
diff --git a/src/modules/module-match.c b/src/modules/module-match.c
index 0bd781d2b..b1693f18c 100644
--- a/src/modules/module-match.c
+++ b/src/modules/module-match.c
@@ -85,7 +85,7 @@ static int load_rules(struct userdata *u, const char *filename) {
pa_assert(u);
if (filename)
- f = fopen(fn = pa_xstrdup(filename), "r");
+ f = pa_fopen_cloexec(fn = pa_xstrdup(filename), "r");
else
f = pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn);
diff --git a/src/modules/module-udev-detect.c b/src/modules/module-udev-detect.c
index 1b1e9c1a6..a12f7c936 100644
--- a/src/modules/module-udev-detect.c
+++ b/src/modules/module-udev-detect.c
@@ -172,7 +172,7 @@ static pa_bool_t is_card_busy(const char *id) {
if (status_file)
fclose(status_file);
- if (!(status_file = fopen(sub_status, "r"))) {
+ if (!(status_file = pa_fopen_cloexec(sub_status, "r"))) {
pa_log_warn("Failed to open %s: %s", sub_status, pa_cstrerror(errno));
continue;
}
diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c
index 41af3bacc..b95023c35 100644
--- a/src/modules/oss/oss-util.c
+++ b/src/modules/oss/oss-util.c
@@ -349,9 +349,9 @@ int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {
if ((n = get_device_number(dev)) < 0)
return -1;
- if (!(f = fopen("/dev/sndstat", "r")) &&
- !(f = fopen("/proc/sndstat", "r")) &&
- !(f = fopen("/proc/asound/oss/sndstat", "r"))) {
+ if (!(f = pa_fopen_cloexec("/dev/sndstat", "r")) &&
+ !(f = pa_fopen_cloexec("/proc/sndstat", "r")) &&
+ !(f = pa_fopen_cloexec("/proc/asound/oss/sndstat", "r"))) {
if (errno != ENOENT)
pa_log_warn("failed to open OSS sndstat device: %s", pa_cstrerror(errno));
diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c
index 62c06f6aa..3eaca4d9d 100644
--- a/src/pulse/client-conf.c
+++ b/src/pulse/client-conf.c
@@ -110,7 +110,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
if (filename) {
- if (!(f = fopen(filename, "r"))) {
+ if (!(f = pa_fopen_cloexec(filename, "r"))) {
pa_log(_("Failed to open configuration file '%s': %s"), fn, pa_cstrerror(errno));
goto finish;
}
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index b57919a44..82a44d84e 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -1804,7 +1804,7 @@ int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, pa_b
if (!fail)
fail = &_fail;
- if (!(f = fopen(fn, "r"))) {
+ if (!(f = pa_fopen_cloexec(fn, "r"))) {
pa_strbuf_printf(buf, "open('%s') failed: %s\n", fn, pa_cstrerror(errno));
if (!*fail)
ret = 0;
diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index dd4a99ee9..34b4d6fe2 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -168,7 +168,7 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void
pa_assert(filename);
pa_assert(t);
- if (!f && !(f = fopen(filename, "r"))) {
+ if (!f && !(f = pa_fopen_cloexec(filename, "r"))) {
if (errno == ENOENT) {
pa_log_debug("Failed to open configuration file '%s': %s", filename, pa_cstrerror(errno));
r = 0;
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 40da8f420..738bf0659 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1600,7 +1600,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
fn = buf;
#endif
- if ((f = fopen(fn, "r"))) {
+ if ((f = pa_fopen_cloexec(fn, "r"))) {
if (result)
*result = pa_xstrdup(fn);
@@ -1634,7 +1634,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
fn = buf;
#endif
- if ((f = fopen(fn, "r"))) {
+ if ((f = pa_fopen_cloexec(fn, "r"))) {
if (result)
*result = pa_xstrdup(fn);
@@ -1661,7 +1661,7 @@ FILE *pa_open_config_file(const char *global, const char *local, const char *env
global = buf;
#endif
- if ((f = fopen(global, "r"))) {
+ if ((f = pa_fopen_cloexec(global, "r"))) {
if (result)
*result = pa_xstrdup(global);
@@ -2560,7 +2560,7 @@ char *pa_machine_id(void) {
* since it fits perfectly our needs and is not as volatile as the
* hostname which might be set from dhcp. */
- if ((f = fopen(PA_MACHINE_ID, "r"))) {
+ if ((f = pa_fopen_cloexec(PA_MACHINE_ID, "r"))) {
char ln[34] = "", *r;
r = fgets(ln, sizeof(ln)-1, f);
diff --git a/src/pulsecore/database-simple.c b/src/pulsecore/database-simple.c
index 1f4caf717..754930db5 100644
--- a/src/pulsecore/database-simple.c
+++ b/src/pulsecore/database-simple.c
@@ -237,7 +237,7 @@ pa_database* pa_database_open(const char *fn, pa_bool_t for_write) {
path = pa_sprintf_malloc("%s."CANONICAL_HOST".simple", fn);
errno = 0;
- f = fopen(path, "r");
+ f = pa_fopen_cloexec(path, "r");
if (f || errno == ENOENT) { /* file not found is ok */
db = pa_xnew0(simple_data, 1);
@@ -480,7 +480,7 @@ int pa_database_sync(pa_database *database) {
errno = 0;
- f = fopen(db->tmp_filename, "w");
+ f = pa_fopen_cloexec(db->tmp_filename, "w");
if (!f)
goto fail;
diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index c92e83126..213e79838 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -143,7 +143,7 @@ static int proc_name_ours(pid_t pid, const char *procname) {
pa_snprintf(bn, sizeof(bn), "/proc/%lu/stat", (unsigned long) pid);
- if (!(f = fopen(bn, "r"))) {
+ if (!(f = pa_fopen_cloexec(bn, "r"))) {
pa_log_info("Failed to open %s: %s", bn, pa_cstrerror(errno));
return -1;
} else {
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index a26dc876a..74600deca 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -1007,7 +1007,7 @@ void pa_memchunk_dump_to_file(pa_memchunk *c, const char *fn) {
/* Only for debugging purposes */
- f = fopen(fn, "a");
+ f = pa_fopen_cloexec(fn, "a");
if (!f) {
pa_log_warn("Failed to open '%s': %s", fn, pa_cstrerror(errno));