[Home]

Summary:ASTERISK-22278: changemonitor returns WARNING[18526]: file.c:1229 ast_writefile permission denied when there is a permission
Reporter:Ido Kanner (ik_5)Labels:
Date Opened:2013-08-12 03:44:58Date Closed:2013-09-26 09:54:16
Priority:MajorRegression?
Status:Closed/CompleteComponents:Applications/app_record
Versions:11.5.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:centos 6 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/LinuxAttachments:
Description:When trying to use changemonitor in manager, asterisk reports the following:

Aug 11 12:32:44] WARNING[18526]: file.c:1229 ast_writefile: Unable to open file /var/punchblock/record/2de73925-a752-4795-b9c2-2867ac6512c2-in.wav: Permission denied
[Aug 11 12:32:44] WARNING[18526]: res_monitor.c:363 __ast_monitor_start: Could not create file /var/punchblock/record/2de73925-a752-4795-b9c2-2867ac6512c2-in
[Aug 11 12:32:44] WARNING[18526]: res_monitor.c:633 __ast_monitor_change_fname: Cannot change monitor filename of channel SIP/support-00000004 to /var/punchblock/record/2de73925-a752-4795-b9c2-2867ac6512c2, monitoring not started

I tried running asterisk as root, and not as the user asterisk with the same result.
The /var/punchblock/record exists, and have the asterisk permissions.
I even symlinked /var/spool/asterisk/monitor as the record directory just as I might be missing something, but nothing.

My code (using adhearsion):
record(async: true) do |event|
 @rec = event.recording.uri
 logger.info "Started recording at #{@rec}"
end
Comments:By: Rusty Newton (rnewton) 2013-08-14 18:17:54.880-0500

Please gather a debug log (including the DEBUG message type) following the instructions here: https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information

Provide the complete log file regarding the above and don't cut out an excerpt, as we need to see the dialplan execution that is calling the file.

Show us the permissions on the file (output of ls or similar)
Show the ps output for what user Asterisk is running as.

If you can provide actual Asterisk dialplan that will be helpful. The Adhearsion code doesn't tell us anything.

By: Ido Kanner (ik_5) 2013-08-18 04:29:31.214-0500

I haven't excerpted, It is using async agi using Adhearsion .

The permission of the directory is:
drwxrwxrwx 2 asterisk asterisk 4096 Jun 12 16:25 record

As I wrote, when using "su - asterisk", I can create a file and both read and write content.
I even executed Asterisk as root, with the same result from asterisk.

By: Walter Doekes (wdoekes) 2013-08-19 03:32:47.529-0500

Well. Asterisk doesn't make up those errors.

- are you sure you were running asterisk as root? check "ps faxu" output.

- are you running chrooted? in that case the directory may not exist where you expect it to be.

- did you check if the file was writable when asterisk was still running? (perhaps you have init scripts that mangle path permission / layout. all directories leading up to the file must have o+x permissions)

- don't symlink the /var/spool/asterisk/monitor directory. just configure that, or better yet, /tmp as the monitor dir and check what happens

- try this for more info:
{noformat}
--- main/file.c (revision 396920)
+++ main/file.c (working copy)
@@ -1154,6 +1154,8 @@
close(fd);
fd = -1;
}
+ } else {
+ ast_log(LOG_WARNING, "open(%s, %u|%u, %u) failed: %d/%s\n", fn, flags, myflags, mode, errno, strerror(errno));
}

if (ast_opt_cache_record_files && (fd > -1)) {
{noformat}

By: David Woolley (davidw) 2013-08-21 05:13:38.612-0500

Also note that root is not immune from SELinux.

By: Walter Doekes (wdoekes) 2013-08-21 05:25:06.930-0500

Excellent point. And apparmor.

Please check the output of dmesg(1) and/or kern.log.

By: Ido Kanner (ik_5) 2013-09-05 01:23:25.740-0500

Nothing special.
Furthermore, when I removed Asterisk and placed freeswitch instead, without changing permissions, even though FS used freeswitch user and group, while Asterisk the "asterisk" user, and it did produced recordings.

No SE-linux or any other process guardian.
Also dmseg does not provide anything special about any error, it's simply exists on this version of Asterisk on two machines now that I'ved tested.

By: David Woolley (davidw) 2013-09-05 05:32:14.203-0500

Free switch is a completely different product, that shares no configuration with Asterisk, so nothing about the behavour of Freeswitch is going to tell you about how Asterisk will handle local files.  (If you meant FreePBX, it complements Asterisk, but doesn't replace it, so if it works with FreePBX, but not bare Asterisk, you have pretty much confirmed you have a configuration error, which should be followed up as a user support issue.)

By: Ido Kanner (ik_5) 2013-09-05 10:10:48.345-0500

Nop, I meant that different processes that are not Asterisk, were able to write to a folder that Asterisk (and only Asterisk) was unable to do so.
Hence, something is wrong with Asterisk.

There is no SELinux, or AppArmor activated.
The disk has no error.
When the directory owner is the asterisk user, and using "su - asterisk", I'm able to read, write and delete file, same as root.
Yet when I execute Asterisk as the Asterisk user, or as the Root user it fails.

Other PBX works on the same directory, with the same code base of what I wrote.
I'm able to duplicate it on a new machine.

So hence, there is a problem somewhere in Asterisk. Either in some settings that I can't figure out, or in the code base of Asterisk that make it work different then other IO operations from different processes.

By: Walter Doekes (wdoekes) 2013-09-05 10:37:23.306-0500

So, what does my LOG_WARNING say .. along with a {{ps faxu | grep asterisk}} and an {{ls -ldL `dirname fn`}} (where fn is the first arg in the LOG_WARNING)?

By: Rusty Newton (rnewton) 2013-09-26 09:54:16.785-0500

Closing this out for lack of activity. We haven't verified there is a bug here yet. Until someone can reproduce it or describe a way to reproduce it, this is a support issue and should be discussed on the mailing lists.