core icon indicating copy to clipboard operation
core copied to clipboard

ownCloud fails to activate apps inside a folder name that contains a dash ("-")

Open arkascha opened this issue 13 years ago • 10 comments

Current stable (OC-4.5.6) fails to active an app that is extracted into a folder that is named with a dash ("-") in the name. This often happens when apps are installed manually, since then the naming of the folder is up to the installing user. Often names like - are chosen. Such naming scheme clearly makes sense from a technical point of view and is perfectly sane on a sytem level. Also ownCloud sees the app and offers it for activation. However during that activation an sql statement fails which is mean to to write the apps preferences:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'appid' cannot be null' in /var/www/bcloud/lib/db.php:731

The reason for column 'appid' being filled with an empty value simply is that ownCloud considers the folder name the app has been installed into as naeme of the app. This is strange in my eyes. Also it completely fails when the folders are named as described above. The name is treated as a mathematical expression by php which tries to build the difference of two invalid numerical values. This attempt results in a value FALSE, so an empty value as appid.

I see three issues that should all be corrected inside OC-core: 1.) Not the apps folder name should be taken as the apps name. I do know that this approach simplifies app handling. However it also leads to problems like the one described here. Those are issues that could be avoided with a different approach. 2.) The result of the decision which name to use for an app should be validated. Maybe by testing the name (appid) against a regular expression. 3.) The error generated is not helpful. Neither is it displayed to the user (the user just gets a generic "failed" error message, if at all), nor does it contain any meaningful information which might help to solve the problem.

Since ownCloud allows to manually install apps the process of handling such apps should be robust enough. To prevent performance issues during normal operation it might make sense to limit checks of those names to handling during the installation/activation of apps.

arkascha avatar Jan 30 '13 12:01 arkascha

would be great if the fix could be provided soon - and also in V5.0.0 :-)

jochenwezel avatar Jan 30 '13 12:01 jochenwezel

Hi, i understand ... for me the problem is that the installer offer it to install... but currently we do not store the exact app location on disk.... the so we use the "app name as dir name" all the time.

Maybe we should mark it as with problem or at least not offer to install it. (tested on master)

eMerzh avatar Feb 07 '13 20:02 eMerzh

Maybe we should mark it as with problem yes, would be great :-)

or at least not offer to install it. not recommended since the user would wonder why his application doesn't appear even if it is on the right place >> heavy confusion ;-)

jochenwezel avatar Feb 08 '13 07:02 jochenwezel

This often happens when apps are installed manually, since then the naming of the folder is up to the installing user

IMO it shouldn't be up to user. App files should be under 'appid' directory by design

VicDeo avatar Feb 08 '13 08:02 VicDeo

On Friday 08 February 2013 00:09:35 VicDeo wrote:

This often happens when apps are installed manually, since then the naming of the folder is up to the installing user

IMO it shouldn't be up to user. App files should be under 'appid' directory by design

This looks clean from a technical point of view. However users do manually install apps all the time (whether it is required or not). So this is something where constant frustration and confusion will result from. That is not good. I don't really understand why it should not be possible to use an arbitrary name as an apps folder. Certainly that involves clean escaping of paths all the time. But from another point of view not doing so and hoping that only accepting a few characters as part of a name prevents problems is nothing but 'hoping that things wong break then' and thus something like a poor mans solution. Either all (sane) characters are allowed as part of a name or manual installation that way must be prevented.

What about introducing a different solution for manual installations? Makes more sense in my eyes anyway: A button "manual installation" that accepts a file archive. That archive is installed just like those downloaded from the app store. This way the folders name is set by the OC application which is cleaner anyway.

Christian Reiner (arkascha) [email protected]

arkascha avatar Feb 08 '13 08:02 arkascha

Btw there are also issues with the classloader which works in the exact same way, see http://doc.owncloud.org/server/5.0/developer_manual/app/classloader.html

Just pointing out further issues.

BernhardPosselt avatar Feb 09 '13 11:02 BernhardPosselt

What’s the status of this issue? Seems like a) it should just work and b) clearly nothing should be exposed to users.

Anyone working on this? @VicDeo?

jancborchardt avatar Aug 05 '13 12:08 jancborchardt

This issue is still not resolved. Wow.

arkascha avatar Nov 15 '14 20:11 arkascha

  1. Computers do not make any difference between an hyphen and a minus character inside a string - except when the string is evaluated. So, avoid the '-' in IDs. Fortunately, there is a "sanitizer" https://github.com/owncloud/core/blob/master/lib/private/app.php#L52
public static function cleanAppId($app) {
    return str_replace(array('\0', '/', '\\', '..'), '', $app);
}
  1. Another constraint might be implemented there: the length of an appId MUST be less or equal to 32. See, at least, the SQL tables oc_appconfig, and oc_preferences, where columns appid are defined as varchar(32). In my opinion, the lack of this constraint could explain some other issues.

  2. According to VicDeo https://github.com/owncloud/core/issues/1376#issuecomment-13280641

App files should be under 'appid' directory by design

To be very clear, for the moment the App files MUST be stored to an "appid" folder. This constraint is well defined, at least inside remote.php: Given a $service, start to retrieve its corresponding $filepath from the database, then extract the first directory from this filepath… will return the $app id. https://github.com/owncloud/core/blob/master/remote.php#L25

$file = \OC::$server->getAppConfig()->getValue('core', 'remote_' . $service);
…
$parts=explode('/', $file, 2);
$app=$parts[0];

In my opinion, the violation of this rather unknown constraint could explain some further issues.

  1. Last, to be honest, this issue should not been labeled as "Enhancement" ; this is only bug. The former adds new features, the latter removes unwanted features. Believe me: I'm a bug maker.

pf18387 avatar Jan 08 '15 13:01 pf18387

Please retry with oC 8.1.1, and re-open if not resolved

RobinMcCorkell avatar Aug 29 '15 22:08 RobinMcCorkell