NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.28k stars 14.27k forks source link

limesurvey: file upload fails #86087

Open davidak opened 4 years ago

davidak commented 4 years ago

Describe the bug

An image upload fails with:

An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder.

To Reproduce Steps to reproduce the behavior:

  1. create container with limesurvey
    [root@nixos:~]# nixos-container create foo --config '
    services.limesurvey.enable = true;
    services.limesurvey.virtualHost =
    {
    hostName = "localhost";
    adminAddr = "webmaster@example.org";
    };
    networking.firewall.allowedTCPPorts = [ 80 ];
    '
  2. start container with nixos-container start foo
  3. get container IP with nixos-container show-ip foo
  4. open admin interface at http://<IP>/admin and login with admin/password
  5. create survey
  6. edit survey -> settings -> theme options -> Advanced options -> Upload an image

Expected behavior image upload works

Screenshots Screenshot from 2020-04-27 02-28-59

Notify maintainers

Metadata

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: services.limesurvey
aanderse commented 4 years ago

@davidak I'm not a maintainer of this nor listed as one. I think you might have the wrong person.

davidak commented 4 years ago

@aanderse yes, but you edited the module before, so i hoped that you can help here.

davidak commented 4 years ago

Note:

this does not help:

        "php_admin_value[upload_tmp_dir]" = "${stateDir}/tmp";
        "php_admin_value[soap.wsdl_cache_dir]" = "${stateDir}/tmp";
        "php_admin_value[opcache.lockfile_path]" = "${stateDir}/tmp";

i still get the error:

An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder.

there is no single /tmp in phpinfo anymore...

where the hell does /tmp come from???

adding /tmp to this makes no difference:

    systemd.tmpfiles.rules = [
      "d /tmp 0777 ${user} ${group} - -"
      "d ${stateDir} 0750 ${user} ${group} - -"
      "d ${stateDir}/tmp 0750 ${user} ${group} - -"
    ];

another idea was that they might use sys_get_temp_dir(), so i set it

"php_admin_value[sys_temp_dir]" = "${stateDir}/tmp";

again same error

i updated to the latest minor version (3.23.0+200813), but it does not solve the problem

OK, going deeper. from watching PHP with strace, i think with /tmp they actualy mean /var/lib/limesurvey/tmp

lstat("/var/lib/limesurvey/tmp", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/var/lib/limesurvey", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/var/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getpid()                                = 922
openat(AT_FDCWD, "/var/lib/limesurvey/tmp/phpRRkKES", O_RDWR|O_CREAT|O_EXCL, 0600) = 5

does it want to write in the nix store?

rename("/var/lib/limesurvey/tmp/phpNTxFfU", "/nix/store/gdv8nq1bjqm2gqa798xs7iysy656zd61-limesurvey-3.23.0+200813/share/limesurvey/upload/themes/survey/generalfiles/EfnxmnFXsAYPznq.jpeg") = -1 EXDEV (Invalid cross-device link)
stat("/var/lib/limesurvey/tmp/phpNTxFfU", {st_mode=S_IFREG|0600, st_size=1585118, ...}) = 0
lstat("/nix/store/gdv8nq1bjqm2gqa798xs7iysy656zd61-limesurvey-3.23.0+200813/share/limesurvey/upload/themes/survey/generalfiles/EfnxmnFXsAYPznq.jpeg", 0x7ffe086587d0) = -1 ENOENT (No such file or directory)

Here a full trace: https://gist.github.com/davidak/aca78ba4ab6c64beb4092619b401e9bc Filename was SparenGoldPK_Header_tablet_970x340.jpg

davidak commented 4 years ago

@offlinehacker can you continue? i don't know how to fix this.

We would like to use limesurvey for NixCon and the next NixOS release.

aanderse commented 4 years ago

@davidak is there a real possibility you'll be using limesurvey on httpd for NixCon, or just an idea to do so? Who is hosting this instance of httpd? Does anyone have any training on building surveys with limesurvey (or time/motivation to learn it)?

davidak commented 4 years ago

@aanderse i'm working on a community survey with the marketing team the last weeks. that's why one of the nixcon organizers asked me if we have an instance ready to host their survey too. i don't have yet and hoped to be able to fix this. but it would still be OK without or just hack in the nixos logo. the alternative is to use paid hosting, but i would find it kind of embarrassing if nixos is not able to host a basic php app

i'm not a fan of httpd (aka apache2) and i guess nginx is now the preferred webserver for nixos modules, but it should be ok for the time the survey runs

aanderse commented 4 years ago

The easiest and quickest course of action may be to configure a NixOS server with nginx, php-fpm, and mariadb then imperatively install limesurvey as a regular php web application - if you're under time constraints.

aanderse commented 4 years ago

After for banging my head on this for a few minutes I'm left to believe this may be a bug upstream. To validate it would be easiest to imperatively install and run through the source code. Something like this may be the culprit...

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

YaroKasear commented 1 month ago

Has anyone figured out a workaround or a fix for this? I can't import a survey.