Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Attachment on FS

OsTicket_version -- v1.9.12 (19292ad)

PHP -- 5.3.27
Apache -- 2.2.17
OS -- FreeBSD 8.2

Hello. We have some problems with plugin "Attachment on FS".
It is clean install, and plugin was enabled before system started.
The problem is with removing ticket, that has attchment (it just show "loading..." and nothing happend ). And then we get such massage:
/home/attachments/G/GAoo4Y4tgDADacTY8M85Y9pbamP7uuuY: Unable to delete file
#0 (root)/include/class.file.php(150): FilesystemStorage->unlink()
#1 (root)/include/class.file.php(633): AttachmentFile->delete()
#2 (root)/include/class.thread.php(181): AttachmentFile->deleteOrphans()
#3 (root)/include/class.thread.php(198): Thread->deleteAttachments()
#4 (root)/include/class.ticket.php(2142): Thread->delete()
#5 (root)/include/class.ticket.php(836): Ticket->delete('')
#6 (root)/include/ Ticket->setStatus(Object(TicketStatus), '')
#7 [internal function]: TicketsAjaxAPI->setTicketStatus('2199')
#8 (root)/include/class.dispatcher.php(145): call_user_func_array(Array, Array)
#9 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('2199/status', Array)
#10 (root)/include/class.dispatcher.php(120): Dispatcher->resolve('2199/status', Array)
#11 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('/tickets/2199/s...', NULL)
#12 (root)/scp/ajax.php(186): Dispatcher->resolve('/tickets/2199/s...')
#13 {main}
Checking those file:
# ll /home/attachments/G/GAoo4Y4tgDADacTY8M85Y9pbamP7uuuY
ls: /home/attachments/G/GAoo4Y4tgDADacTY8M85Y9pbamP7uuuY: No such file or directory

Attachments is not removing from disk (disk space doesnt increase).

Base folder for attachment files: /home/attachments

Permissions on the folder, subfolders and files (tree view):
( we changed permissions only on /home/attachments )
drwsrwsrwx  66 mailnull    nobody      1024 Oct 18 06:58 attachments
d-wxr-xr-x  2 mailnull  nobody  1024 Oct 22 06:58 1
-rw-r--r--  1 mailnull  nobody   10607 Oct  6 21:54 11iucvqT5ru6bafCb5ULYXZeOrSyMy4E
-rw-r--r--  1 mailnull  nobody    1803 Oct  8 18:46 1FZ0hs2eO-B9NadUD86COlhyffcnO7Vg
-rw-r--r--  1 mailnull  nobody   43910 Oct 12 10:47 1G3UFt7uhNZihOS7QiDkPc_-T7SVyT8k
-rw-r--r--  1 mailnull  nobody   17058 Oct 20 11:28 1KehapzA4Ms5dlwMMEEH17aUeIkXdWc8
d-wxr-xr-x  2 mailnull  nobody  1024 Oct 27 09:49 2
d-wxr-xr-x  2 mailnull  nobody   512 Oct 28 10:34 3

We have read a lot, but didn`t find answer. Changed permissions and owners(nobody:nobody) to folders, subfolders and files, changed attachment path.
We use php as apache module, not Fast_CGI
(ServerAPI: Apache 2.0 Handler. So cant enable/disable AJAX due to )

I would appreciate any help.


  • edited October 2015
    (didnt added)image
  • ADDED:
    Even if we change perm to 777 for folders and files, ticket removes correctly BUT attachment does not removed from disk.
  • Anything in your PHP error logs?
  • edited November 2015
    no, nothing in php_errors.log
    sometimes we get
    /home/attachments/n/nExnJynFSQd_LreKbU36UfGEue0yoZFs: Unable to delete file
    #0 (root)/include/class.file.php(150): FilesystemStorage->unlink()
    #1 (root)/include/class.file.php(633): AttachmentFile->delete()
    #2 (root)/include/class.thread.php(181): AttachmentFile->deleteOrphans()
    #3 (root)/include/class.thread.php(198): Thread->deleteAttachments()
    #4 (root)/include/class.ticket.php(2142): Thread->delete()
    #5 (root)/include/class.ticket.php(836): Ticket->delete('')
    #6 (root)/include/ Ticket->setStatus(Object(TicketStatus), '')
    #7 [internal function]: TicketsAjaxAPI->setSelectedTicketsStatus('deleted')
    #8 (root)/include/class.dispatcher.php(145): call_user_func_array(Array, Array)
    #9 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('status/deleted', Array)
    #10 (root)/include/class.dispatcher.php(120): Dispatcher->resolve('status/deleted', Array)
    #11 (root)/include/class.dispatcher.php(38): UrlMatcher->dispatch('/tickets/status...', NULL)
    #12 (root)/scp/ajax.php(186): Dispatcher->resolve('/tickets/status...')
    #13 {main}

    ll -h /home/attachments/n/nExnJynFSQd_LreKbU36UfGEue0yoZFs
    -rwxrwxrwx 1 mailnull nobody 5.3M Oct 28 15:50 /home/attachments/n/nExnJynFSQd_LreKbU36UfGEue0yoZFs

    Any ides?

    We can change owner to nobody:nobody (recursive) and then we didn`t get any errors, BUT attachment doesn`t remove. (I mean -- ticket removed; attachment not removed)

  • what user does your web server software run as?
    That user needs permissions to that folder.
  • edited November 2015
    thk for reply

    Apache is running under "nobody:nobody" (explanation - user:group)
    BUT mail is handled by sendmail, so attachment is placed by "mailnull:nobody" (if I understand correctly)

    We tried to run in cron every minute:

    chown -R nobody:nobody /home/attachment
    chmod -R +w /home/attachment

    in this case, there is no errors, BUT folder "/home/attachment" didn`t change its size (so, attachment didnt removed)

    For now, I`m trying to run PHP with different user (maybe user with greater permissions will remove attachments, because running chown under cron is lame)

  • PHP is generally executed as the user that your Apache is running as.
    So it might just be easier to change your apache user.
  • I wish I could...
    but no, we cant change Apache user for security reasons, just because in the same server we have webmail (RoundCube) with few thousand of users.
    So, for now I`ll try to use SuExec or FastCGI (in this case, I can use AJAX, and I hope it will help).

    Do you think this is only owner/permissions trouble?
  • That would be my first guess.  My second guess is that the the delete verb isnt allowed on the server.
  • But, if I change permissions to 777 (full access), attachment still not removed.
  • and does your server allow the delete verb?
  • excuse me, cant understand you,
    What do you mean "delete verb"?
    This is our own server, not VPS or shared, so we have full access for all its components.

  • I think he ment that possibly the method "delete" is limited in your .htacess of your apache server.
    It is described in the apache documentation -> <limit> :

  • i see,
    Nope, i think its something else, because:

    <Directory "/path/to/osticket-v1.9.12">
            Order allow,deny
            Allow from all
            AllowOverride all

    ... and these files ( find . -name ".htaccess" -print ) we didn`t change

    Besides, attachment is located in /home/attachments.
    Now, I`ve tried to change location of  attachment folder, into parent folder of osTicket (/path/to/osticket/attachment).
    Send ticket with attachment. System creates new subfolder (A, 2, t -- and so on).
    chmod -R 777 to /path/to/osticket/attachment (full access to all dir, subdir and files) and try to remove ticket. And - nothing changed. Still ticket removes, but not attachment.
    chown -R nobody:nobody -- still the same.
    chown + chmod -- and again nothing.

    what else can I try?

  • edited November 2015
    ok, I get up osTicket on new server
    FreeBSD 10.1
    PHP 5.6.12 (cli)
    Apache/2.4.10 (FreeBSD)
    Attachments is in /usr/local/www/apache24/data/ (chmod -R 4777 *)
    Apache user www:www

    <Directory "/usr/local/www/apache24/data">
                    Order allow,deny               
                    Allow from all                 
                    AllowOverride None             

    Still the same.
    Can somebody check, maybe it is normal behavior for AttachmentFS plugin ?

    Now I see those options:
    - save attch in DB;
    - user different Apache (prefork, itk ..) and PHP (CGI, FastCGI ...), to find working configuration;

  • I want to ask such a question:
    Is it normal behavior to "Attachments on the FS" plugin NOT to actually remove attachment from disk while ticket (that consist those attachment) was removed.
    (i`m sorry, but this is the second try, to figure out this issue.
  • @shelsi

    That's a good question. I can see in my installations (1.9.12) the behavior with the filesystem plugin is like you describe it: deleting a ticket doesn't delete the associated attachments.

    However the info text in the delete popup implies that it will be deleted ("Deleted tickets CANNOT be recovered, including any associated attachments.").

  • @mfelber
    thanks a lot for your answer,
    Can you describe (in general) configuration of your server (Os, Apache version, PHP version (mod_php, FastCGI)) ? Maybe, you have the same config as mine.
    Now what, write to developer?

  • @shelsi

    This is my config: 
    osTicket Version: v1.9.12 (19292ad) — Up to date 
    Web Server Software: Apache 
    MySQL Version 5.5.44

    PHP Version 5.5.30

    I have no errors in my osticket system log or in the web server error log.

    But I don't think that this behavior only occurs in our two environments. I think this is the general behavior.

    I guess either nobody has noticed it or nobody cares, since it is no big deal ;-)

  • @mfelber
    Its a pity, because it is deal for my needs: for a one mouth we got 200Mb of attachments, and we need to keep some of tickets for a few years. I see two options here:
    • storage attachments in DB (need a perfect optimizations of DB, so unprofitable),
    • or change source code of plugin, to delete, or (somehow) mark attachment to be deleted, and remove them using bash script.

    What other options can you advice?

  • @shelsi

    Maybe the cli is a good option for you to reach your goals (see Jared's use case):

  • This also occurs when you store the attachments in the database. 

    I opened an issue report on github to clarify this:

  • @shelsi 

    The attachments will be deleted after 24 hours via the cron call:

  • /facepalm
    I completely forgot about that!  Thanks @mfelber
  • @ntozier I’m glad that I could help (thanks to @infectormp and his tip).

  • last help, please
    Where I must insert this code:
    $files = static::objects()
    'attachments__object_id__isnull' => true,
    'ft' => 'T',
    'created__lt' => new DateTime('now -1 day'),

    foreach ($files as $f) {
    if (!$f->delete())
    Into include/class.cron.php (after 49 line)?
    And than run include/class.cron.php via crontab?

  • edited November 2015

    Why do you want to insert this code?

    You only have to call the cron.php in the folder "api".

    For fetching emails a cron job is recommended in osticket (not the autocron).

    The same cron job will trigger deleting the attachments.

    On windows system you would use the task scheduler on linux system a local cron job.

    In this "task" or cron job you specify that the cron.php will be executed in a certain inverval.

    That's all, it is described here:

    If you could not use a local cron job you could use an alternative way via a rcron (remote cron).

  • I'm insteresting about this. Really, do you talk about a task to remove attachments?
  • This thread is from 2015.
    If you have a question please start a new thread.
This discussion has been closed.