aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-21 19:44:20 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2006-12-21 19:44:20 +0000
commit322326058e7ad82eeb971673895f71bcc3230244 (patch)
tree9213841cb68bd7576686b8baea3c095dcc4fcdd2
parent90ea800e9b095f3bd03c16373cd16a7a9a3c7bf9 (diff)
a quick fix to app_sms.c to get rid of cursed compiler warnings so I can compile under --enable-dev-mode
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48767 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_chanspy.c4
-rw-r--r--apps/app_dictate.c4
-rw-r--r--apps/app_directory.c2
-rw-r--r--apps/app_festival.c2
-rw-r--r--apps/app_meetme.c2
-rw-r--r--apps/app_mixmonitor.c2
-rw-r--r--apps/app_record.c2
-rw-r--r--apps/app_sms.c8
-rw-r--r--apps/app_voicemail.c2
-rw-r--r--cdr/cdr_sqlite.c2
-rw-r--r--channels/chan_iax2.c2
-rw-r--r--channels/chan_zap.c4
-rw-r--r--include/asterisk.h10
-rw-r--r--main/app.c4
-rw-r--r--main/db.c2
-rw-r--r--main/file.c2
-rw-r--r--res/res_agi.c2
-rw-r--r--res/res_convert.c2
-rw-r--r--res/res_monitor.c4
19 files changed, 36 insertions, 26 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index cf1e4759d..61d8afab5 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -617,7 +617,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
char filename[512];
snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
- if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644)) <= 0) {
+ if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
fd = 0;
}
@@ -701,7 +701,7 @@ static int extenspy_exec(struct ast_channel *chan, void *data)
char filename[512];
snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
- if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0644)) <= 0) {
+ if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
fd = 0;
}
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 0c46118e4..661a4a237 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -150,7 +150,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
}
snprintf(path, len, "%s/%s", base, filein);
- fs = ast_writefile(path, "raw", NULL, O_CREAT|O_APPEND, 0, 0700);
+ fs = ast_writefile(path, "raw", NULL, O_CREAT|O_APPEND, 0, AST_FILE_MODE);
mode = DMODE_PLAY;
memset(&flags, 0, sizeof(flags));
ast_set_flag(&flags, DFLAG_PAUSE);
@@ -307,7 +307,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
} else {
oflags |= O_APPEND;
}
- fs = ast_writefile(path, "raw", NULL, oflags, 0, 0700);
+ fs = ast_writefile(path, "raw", NULL, oflags, 0, AST_FILE_MODE);
if (ast_test_flag(&flags, DFLAG_TRUNC)) {
ast_seekstream(fs, 0, SEEK_SET);
ast_clear_flag(&flags, DFLAG_TRUNC);
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 3b1d29e11..c5f083c3c 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -142,7 +142,7 @@ static void retrieve_file(char *dir)
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
break;
}
- fd = open(full_fn, O_RDWR | O_CREAT | O_TRUNC, 0770);
+ fd = open(full_fn, O_RDWR | O_CREAT | O_TRUNC, AST_FILE_MODE);
if (fd < 0) {
ast_log(LOG_WARNING, "Failed to write '%s': %s\n", full_fn, strerror(errno));
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 7af2e78a6..1fa935e0b 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -433,7 +433,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
snprintf(cachefile, sizeof(cachefile), "%s/%s", cachedir, MD5Hex);
fdesc=open(cachefile,O_RDWR);
if (fdesc==-1) {
- fdesc=open(cachefile,O_CREAT|O_RDWR,0777);
+ fdesc=open(cachefile,O_CREAT|O_RDWR,AST_FILE_MODE);
if (fdesc!=-1) {
writecache=1;
strln=strlen((char *)data);
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 003363fc1..0a3e4a82b 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -2874,7 +2874,7 @@ static void *recordthread(void *args)
break;
}
if (!s && cnf->recordingfilename && (cnf->recordingfilename != oldrecordingfilename)) {
- s = ast_writefile(cnf->recordingfilename, cnf->recordingformat, NULL, flags, 0, 0644);
+ s = ast_writefile(cnf->recordingfilename, cnf->recordingformat, NULL, flags, 0, AST_FILE_MODE);
oldrecordingfilename = cnf->recordingfilename;
}
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 1171fc89e..210e18968 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -256,7 +256,7 @@ static void launch_monitor_thread(struct ast_channel *chan, const char *filename
}
/* Move onto actually creating the filestream */
- mixmonitor->fs = ast_writefile(file_name, ext, NULL, oflags, 0, 0644);
+ mixmonitor->fs = ast_writefile(file_name, ext, NULL, oflags, 0, AST_FILE_MODE);
if (!mixmonitor->fs) {
ast_log(LOG_ERROR, "Cannot open %s.%s\n", file_name, ext);
free(mixmonitor);
diff --git a/apps/app_record.c b/apps/app_record.c
index b38944aef..e06d84a46 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -265,7 +265,7 @@ static int record_exec(struct ast_channel *chan, void *data)
flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
- s = ast_writefile( tmp, ext, NULL, flags , 0, 0644);
+ s = ast_writefile( tmp, ext, NULL, flags , 0, AST_FILE_MODE);
if (!s) {
ast_log(LOG_WARNING, "Could not create file %s\n", filename);
diff --git a/apps/app_sms.c b/apps/app_sms.c
index 0d0a0c1e1..c68d3b958 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -245,7 +245,7 @@ typedef struct sms_s {
int protocol; /*!< ETSI SMS protocol to use (passed at app call) */
int oseizure; /*!< protocol 2: channel seizure bits to send */
int framenumber; /*!< protocol 2: frame number (for sending ACK0 or ACK1) */
- unsigned char udtxt[SMSLEN]; /*!< user data (message), PLAIN text */
+ char udtxt[SMSLEN]; /*!< user data (message), PLAIN text */
} sms_t;
/* different types of encoding */
@@ -707,7 +707,7 @@ static unsigned char packaddress (unsigned char *o, char *i)
static void sms_log (sms_t * h, char status)
{
if (*h->oa || *h->da) {
- int o = open (log_file, O_CREAT | O_APPEND | O_WRONLY, 0666);
+ int o = open (log_file, O_CREAT | O_APPEND | O_WRONLY, AST_FILE_MODE);
if (o >= 0) {
char line[1000], mrs[3] = "", *p;
unsigned char n;
@@ -1184,14 +1184,14 @@ static int sms_handleincoming_proto2 (sms_t * h)
msgsz=20-1;
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "SMS-P2 Origin#%02X=[%.*s]\n",msg,msgsz,&h->imsg[f]);
- ast_copy_string (h->oa, &h->imsg[f], msgsz+1);
+ ast_copy_string (h->oa, (char*)(&h->imsg[f]), msgsz+1);
break;
case 0x18: /* Destination (from TE/phone) */
if (msgsz>=20)
msgsz=20-1;
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "SMS-P2 Destination#%02X=[%.*s]\n",msg,msgsz,&h->imsg[f]);
- ast_copy_string (h->da, &h->imsg[f], msgsz+1);
+ ast_copy_string (h->da, (char*)(&h->imsg[f]), msgsz+1);
break;
case 0x1C: /* Notify */
if (option_verbose > 2)
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 61ced5661..9a02f38c1 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1072,7 +1072,7 @@ static int retrieve_file(char *dir, int msgnum)
ast_odbc_release_obj(obj);
goto yuck;
}
- fd = open(full_fn, O_RDWR | O_CREAT | O_TRUNC, 0770);
+ fd = open(full_fn, O_RDWR | O_CREAT | O_TRUNC, VOICEMAIL_FILE_MODE);
if (fd < 0) {
ast_log(LOG_WARNING, "Failed to write '%s': %s\n", full_fn, strerror(errno));
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
diff --git a/cdr/cdr_sqlite.c b/cdr/cdr_sqlite.c
index 146f7a209..c56fd4d9c 100644
--- a/cdr/cdr_sqlite.c
+++ b/cdr/cdr_sqlite.c
@@ -181,7 +181,7 @@ static int load_module(void)
/* is the database there? */
snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR);
- db = sqlite_open(fn, 0660, &zErr);
+ db = sqlite_open(fn, AST_FILE_MODE, &zErr);
if (!db) {
ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr);
free(zErr);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 1ada3a24d..6456f4637 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1414,7 +1414,7 @@ static int try_firmware(char *s)
ast_log(LOG_WARNING, "Cannot open '%s': %s\n", s, strerror(errno));
return -1;
}
- fd = open(s2, O_RDWR | O_CREAT | O_EXCL);
+ fd = open(s2, O_RDWR | O_CREAT | O_EXCL, AST_FILE_MODE);
if (fd < 0) {
ast_log(LOG_WARNING, "Cannot open '%s' for writing: %s\n", s2, strerror(errno));
close(ifd);
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 127b0ed03..5f267e2e7 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -10242,7 +10242,7 @@ static int start_pri(struct zt_pri *pri)
for (i = 0; i < NUM_DCHANS; i++) {
if (!pri->dchannels[i])
break;
- pri->fds[i] = open("/dev/zap/channel", O_RDWR, 0600);
+ pri->fds[i] = open("/dev/zap/channel", O_RDWR);
x = pri->dchannels[i];
if ((pri->fds[i] < 0) || (ioctl(pri->fds[i],ZT_SPECIFY,&x) == -1)) {
ast_log(LOG_ERROR, "Unable to open D-channel %d (%s)\n", x, strerror(errno));
@@ -10359,7 +10359,7 @@ static int handle_pri_set_debug_file(int fd, int argc, char **argv)
if (ast_strlen_zero(argv[4]))
return RESULT_SHOWUSAGE;
- myfd = open(argv[4], O_CREAT|O_WRONLY);
+ myfd = open(argv[4], O_CREAT|O_WRONLY, AST_FILE_MODE);
if (myfd < 0) {
ast_cli(fd, "Unable to open '%s' for writing\n", argv[4]);
return RESULT_SUCCESS;
diff --git a/include/asterisk.h b/include/asterisk.h
index 6579496f7..7bbb75f3a 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -31,6 +31,16 @@
#include "asterisk/paths.h"
+/* Default to allowing the umask or filesystem ACLs to determine actual file
+ * creation permissions
+ */
+#ifndef AST_DIR_MODE
+#define AST_DIR_MODE 0777
+#endif
+#ifndef AST_FILE_MODE
+#define AST_FILE_MODE 0666
+#endif
+
#define DEFAULT_LANGUAGE "en"
#define DEFAULT_SAMPLE_RATE 8000
diff --git a/main/app.c b/main/app.c
index b2e2b8d5e..33c6bd57d 100644
--- a/main/app.c
+++ b/main/app.c
@@ -571,7 +571,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
end = start = time(NULL); /* pre-initialize end to be same as start in case we never get into loop */
for (x = 0; x < fmtcnt; x++) {
- others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, O_TRUNC, 0, 0700);
+ others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, O_TRUNC, 0, AST_FILE_MODE);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "x=%d, open writing: %s format: %s, %p\n", x, prepend ? prependfile : recordfile, sfmt[x], others[x]);
@@ -943,7 +943,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
}
snprintf(fs, strlen(path) + 19, "%s/.lock-%08lx", path, ast_random());
- fd = open(fs, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ fd = open(fs, O_WRONLY | O_CREAT | O_EXCL, AST_FILE_MODE);
if (fd < 0) {
ast_log(LOG_ERROR, "Unable to create lock file '%s': %s\n", path, strerror(errno));
return AST_LOCK_PATH_NOT_FOUND;
diff --git a/main/db.c b/main/db.c
index 34ebfac52..735c93db1 100644
--- a/main/db.c
+++ b/main/db.c
@@ -62,7 +62,7 @@ AST_MUTEX_DEFINE_STATIC(dblock);
static int dbinit(void)
{
- if (!astdb && !(astdb = dbopen((char *)ast_config_AST_DB, O_CREAT | O_RDWR, 0664, DB_BTREE, NULL))) {
+ if (!astdb && !(astdb = dbopen((char *)ast_config_AST_DB, O_CREAT | O_RDWR, AST_FILE_MODE, DB_BTREE, NULL))) {
ast_log(LOG_WARNING, "Unable to open Asterisk database\n");
return -1;
}
diff --git a/main/file.c b/main/file.c
index c5fb522d3..f67fbec29 100644
--- a/main/file.c
+++ b/main/file.c
@@ -214,7 +214,7 @@ static int copy(const char *infile, const char *outfile)
ast_log(LOG_WARNING, "Unable to open %s in read-only mode\n", infile);
return -1;
}
- if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0) {
+ if ((ofd = open(outfile, O_WRONLY | O_TRUNC | O_CREAT, AST_FILE_MODE)) < 0) {
ast_log(LOG_WARNING, "Unable to open %s in write-only mode\n", outfile);
close(ifd);
return -1;
diff --git a/res/res_agi.c b/res/res_agi.c
index 042fdbfbc..55f5c6533 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -961,7 +961,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
if (res) {
fdprintf(agi->fd, "200 result=%d (randomerror) endpos=%ld\n", res, sample_offset);
} else {
- fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0), 0, 0644);
+ fs = ast_writefile(argv[2], argv[3], NULL, O_CREAT | O_WRONLY | (sample_offset ? O_APPEND : 0), 0, AST_FILE_MODE);
if (!fs) {
res = -1;
fdprintf(agi->fd, "200 result=%d (writefile)\n", res);
diff --git a/res/res_convert.c b/res/res_convert.c
index d856c8faf..628381aa9 100644
--- a/res/res_convert.c
+++ b/res/res_convert.c
@@ -88,7 +88,7 @@ static int cli_audio_convert(int fd, int argc, char *argv[])
ast_cli(fd, "'%s' is an invalid filename!\n", argv[3]);
goto fail_out;
}
- if (!(fs_out = ast_writefile(name_out, ext_out, NULL, O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
+ if (!(fs_out = ast_writefile(name_out, ext_out, NULL, O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
ast_cli(fd, "Unable to open output file: %s\n", argv[3]);
goto fail_out;
}
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 934356aa7..515352e75 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -197,7 +197,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
}
if (!(monitor->read_stream = ast_writefile(monitor->read_filename,
monitor->format, NULL,
- O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
+ O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
ast_log(LOG_WARNING, "Could not create file %s\n",
monitor->read_filename);
free(monitor);
@@ -209,7 +209,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
}
if (!(monitor->write_stream = ast_writefile(monitor->write_filename,
monitor->format, NULL,
- O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
+ O_CREAT|O_TRUNC|O_WRONLY, 0, AST_FILE_MODE))) {
ast_log(LOG_WARNING, "Could not create file %s\n",
monitor->write_filename);
ast_closestream(monitor->read_stream);