Install/Update Modules/Themes within Drupal Interface

Events happening in the community are now at Drupal community events on www.drupal.org.
cwgordon7's picture

Moved to official ideas list at http://drupal.org/node/237532

Here it is, the traditional proposal: a module that automatically fetches modules (and themes, theme engines, etc.) from drupal.org and uploads them to your site.

Unlike previous attempts, however, this will not be a security risk; it will use its own (s)ftp engine to upload fetched files to the site. The password will not be stored; the user will be prompted for it every time.

This project consists of main parts:

  1. Creation of an (s)ftp client or the adaptation of an existing gpl (s)ftp client to fit Drupal's needs.
  2. Adding the ability to use this module to fetch other modules, themes, etc from drupal.org.
  3. Adding the ability to use this (s)ftp client to upload modules, themes, etc to the appropriate place on each Drupal site.

The benefit of this project is:
Increased usability.

Mentors:
TBD. I would not be a good mentor for this as I know next to nothing about it. :(

Difficulty:
Pretty hard. But not impossible. :)

Comments

You might want to look into

gdd's picture

You might want to look into Wim Leer's CDN module for moving files around. It has a built in file transfer mechanism with pluggable interfaces for whatever you need (although currently only ftp is built.) I had been wanting to send him a patch which abstracts the file transfer stuff into its own distinct module for easier usage in situations exactly like this one.

http://drupal.org/project/cdn

Oh, cool

cwgordon7's picture

Then that makes it easier. So this is probably a better SoC project now. :)

seems great - some enhancements

greggles's picture

A few things that I'd like to see...

  • Ideally you'd refactor the code from CDN and/or media_mover so that the (s)ftp code is a separate module and can be re-used elsewhere.
  • When the files get downloaded from d.o the md5 of the tar file should be checked prior to installation and checked against the values listed on d.o. I think those values are available via the xml that gets used by udpate(_status) but I'm not sure. You could also ask the user to paste the md5 into the form - that way the module is somewhat protected against DNS poisoning.

This seems like a great proposal to me and those two items are really "nice to have".

--
Open Prediction Markets | Drupal Dashboard

challengingly cool!

lut4rp's picture

this is very cool, and definitely challenging, I would love to take on something like this! thanks cwgordon7...

I like it.

JoshuaRogers@drupal.org's picture

I too find this to be highly intriguing. I would very much like to do work with this.

Clarification

JoshuaRogers@drupal.org's picture

Would it be acceptable to use PHP's built in ftp wrapper to handle most of the ftp needs of the system? I believe this would still yield the desired code security / stability without incurring the problem of increased code quantities. It would also natively support SSL.

Thank you for your time,
Joshua Rogers

s9y SPARTACUS

houndbee's picture

I would recommend taking a look at the Serendipity Project's SPARTACUS which uses XML+version control to do exactly this for s9y.

I was closely involved in the project when SPARTACUS was developed, and would be more than glad to answer questions.

For those who came in late ;-), Serendipity is an open-source blogging engine written in PHP.

Cheers,
-K

Source List

JoshuaRogers's picture

Would there be any possibility of enabling feeds for the theme and module pages? Otherwise the client would have to load the entire page and then parse it. Said parser could not be guaranteed to continue working if the theme ever changed. Not that that is particularly likely, but it just seems that the second option would involve much unneccessary overhead and taxing of the d.o server.

There is already

cwgordon7's picture

There is already xml data available for project releases. It is used by the update status module. I do not see that this would be particularly overtaxing on the d.o. server, as it is simply replacing manual downloads with automated ones.

Hi, looks interesting -

alex_b's picture

Hi, looks interesting - could you give it a more descriptive title, please? thank you!

agreed

greggles's picture

I changed the title - cwgordon07 or anyone else with the permissions should feel free to refine it.

--
Open Prediction Markets | Drupal Dashboard

I'm interested

zim@drupal.org's picture

I really like this idea. How can I get involved? How can I start? I know it's a big project, and I don't want to take something I can't do. Currently, I'm a student (and here we are just starting -- summer+holidays are gone!) and I have time besides the university time. But I don't know how much time it will consume studying in the next months. What can I do? Thanks!

Let me fire you over the

tonyn's picture

Let me fire you over the link.. Sec.

http://code.google.com/opensource/gsoc/2008/faqs.html - FAQ
http://groups.google.com/group/google-summer-of-code-announce/web/guide-... - getting into the Summer of Code interface

+1

Crell's picture

PHP 5 offers an FTP file wrapper and an ssh/scp file wrapper (optional) for just this sort of thing. This would be hugely beneficial, and is one of the recently discussed benefits of moving to PHP 5-only.

Any such module would need to have a good fallback process, though. Try SFTP, if that fails try FTP, if that fails don't work. :-) This should be a fairly straightforward process, but with lots of failure points that need to be handled.

I may be missing a part of the picture here, but...

mflage's picture

.. why not simply use HTTP to transfer the files? The update status module already checks for updated versions of the modules you've already have installed and retrieves the direct link to the downloadable tarball for the module in question. So why not use something similar to retrieve the different URLs and then use file() and gzopen() or something similar to retrieve this module directly? The only challenge I see is how you overcome the fact that you probably haven't got write access to the file system, so some additional rights has to be set to be able to accomplish the actual unpacking of the tarball.

But as I said, I may be missing a part of the picture here :)

you pretty much said it yourself.

catch's picture

Granting "additional rights" to the webserver to write modules into your directories, means allowing the application to write to itself - which means immediately opening yourself up to many, many security issues.

Doing it via sftp/ftp, you're running as your actual user account on the server (and would be prompted for your password whenever installing/upgrading) - so there's no way someone could install all kinds of crazy stuff to your PC if they managed to escalate permissions or otherwise get access to the download interface.

Not to mention there's 2-3 modules in contrib that do it that way already. All with big red warnings on them from the security team.

Drupal module?

mflage's picture

But should this still be added as a Drupal module that adds itself to the Drupal administrative panel, or is this more like a "third-party" tool that runs as some daemon on the machine? The Drupal module part of this implementation communicates to the underlying service that then does the downloading and gunzipping? Have I fully understood it then? :) (he said, with his fingers crossed and self-respect on the line :)

As far as I understand it,

catch's picture

As far as I understand it, which isn't all that much, there's a drupal module which acts as a front end GUI to it's own s/ftp client (which will be heavily dependent on PHP5's ftp support and hence hopefully very small). The Drupal module lets you choose what to install/upgrade - but the actually grabbing and writing of the files is done using the user account privileges server - not the webserver permissions. This isn't trivial to do, which is why it hasn't been done yet (and why it'll hopefully make a very cool GSoC project for someone) - it also needs additional security checks to ensure that the files being downloaded are genuine etc. To get the convenience benefits this promises, the UI has to be in Drupal, whilst Drupal absolutely can't have privileges to write to itself - which is where the s/ftp layer comes in.

What does exist at the moment is Drush, which provides an apt-like way to install and upgrade modules from the command line, and is very nice.

Automatic but not too automatic

skessler's picture

This should be automatic but not too automatic in that the modules should download but not be overwritten without the direct interaction of the admin. I like the idea of having to match MD5 codes - but only if the module provides a link to the d.o pages with the MD5 codes, I don't want to make it an all day process to find the codes.

Because we know that this will make Drupal a more open environment for less technical users we also need to address the backup question in this post as well. Can we backup the tables specifically altered by the specific update that is being installed and can we back up the folder for the specific module as well with the ability to revert to the old version of the module.

So the work flow looks like this in my mind.

  1. Install update-helper module (name TBD)
  2. Enable or disable automatic downloads via s(ftp) or ssh to a downloads area directory or disable to be able to fetch from an interface
  3. Once files are downloaded module installed copies tables to be effected and the current module folder to archive
  4. New module is copied over old module and update.php is ran

I am not a programmer and I could be oversimplifying some of this but I think that this would be a big help to make Drupal more availible to more users. I am lucky enough to have SSH from my host but not everyone has the luxury. This is a great SOC project.

Owner and Lead Consultant
Denver DataMan

backups

catch's picture

For backup, there's a separate GSoC proposal for that here: http://groups.drupal.org/node/10060 - it's related, but it's a very big task in itself.

I agree all isntall/upgrades should be triggered manually (very manually) though. The idea of it all happening in the background one day scares the crap out of me.

Clarification

adamdicarlo's picture

I want to see if I understand the idea here. For example, where "drupalbox" is the server on which drupal is run:

  1. I tell the magic Drupal Module/Theme installer (DMTI) I want to install package X.
  2. I input my (non-root/apache) *nix login username/password for drupalbox.
  3. DMTI downloads package into my homedir on drupalbox.
  4. Using SFTP, it then does a local transfer of the package from my homedir to the drupal installation's "modules" or "themes" dir.
  5. Somewhere along the way, it does "tar xzf" to unpack the module.

Is this about right? (Or would/could it be more along the lines of running a shell script as the non-root, non-apache user whose credentials were given?)

close

greggles's picture
  1. I tell the magic Drupal Module/Theme installer (DMTI) I want to install package X.
  2. I input my (non-root/apache) *nix login username/password for drupalbox which is probably known to most users as their "(S)FTP login"
  3. DMTI downloads package into the Drupal temp directory on drupalbox.
  4. Using SFTP, it then does a local transfer of the package from my Drupal temp directory to the drupal installation's "modules" or "themes" dir.
  5. Somewhere along the way, it does "tar xzf" to unpack the module.

How does that seem?

The "magic DMTI" is a module within Drupal, so you do all these things from within the Drupal interface and it runs inside of the PHP process.

--
Open Prediction Markets | Drupal Dashboard

Many shared hosting use

jenot's picture

Many shared hosting use fcgi-suexec and suphp.
So module can check or ask about uploading to local filesystem.

I think it is very good idea because:
1 user can be in fcgi based system
2 user can be in suphp based system
3 user can be in mod_phpX based system then we upload to local (s)ftp
4 user can be in mod_phpX based system and have scp proto

Personally I dont really

tjholowaychuk's picture

Personally I dont really think this kind of functionality belongs in a module state. Although saying that, it would certainly be more usable for some people, but I would prefer the CLI method of an apt-get approach, rather than having the overhead of a module which is essentially is just a utility.

vision media
350designs
Print Huge Edmonton Printing Services
Design Inspiration Gallery

Have you seen Drush?

catch's picture

Have you seen Drush? http://drupal.org/project/drush

Yup

+1; remember to look at best practice

Paul Natsuo Kishimoto's picture

Huge huge huge +1! I've been begging whoever would listen for a module like this for a long time... I think mostly through annoying, irrelevant comments on update_status issues. I'd love to code it myself, but I don't know if I have the time to do it justice. When I switched from Windows to Ubuntu a few years ago, the ease of installing software through Add/Remove Applications and Synaptic blew me away. It would be awesome if a Drupal package manager could have the same impact.

The implementer should consider "best practice" in package management (which is basically what this appears to be). Many Linux distributions have their own package managers: apt, rpm, and portage are mature examples. The PEAR library also includes a package manager. I realize that these are complex and multi-layered programs, but there are lots of lessons to be learned for the simpler Drupal context. For example:

  • Most package managers can fetch a list of all available packages from a repository (here, drupal.org). Does the XML-RPC protocol used by update_status support this? Maybe it should.
  • Packages can also be installed from the local disk. E.g. in Drupal, a user could upload a .tar.gz through the web, and the package manager would take care of installing it.
  • Apt uses MD5 sums, as suggested by many here. These are provided in the aforementioned package lists. There are also encryption keys to ensure the package manager is talking to the actual repository (not a man-in-the-middle).
  • Multiple repositories can be used (maybe not urgent, because modules are mostly centralized on drupal.org).
  • @denverdataman: Options for pinning (not doing any upgrades for specified packages), automatic upgrades (at some interval, via cron), and policies (automatically update the package list only OR automatically install security fixes only OR automatically install all updates). Note that the "automatic package list update" is essentially what the update_status module does; but it only fetches a partial list.
  • @tjholowaychuk: The package manager is a package itself in most distributions, and can therefore update itself.
  • Automated update times are slightly randomized to avoid hammering the repository on, say, Friday at midnight GMT.
  • Dependency resolution, usually with prompts to the user to install packages required by the one they asked for. This information could be extracted from module .info files and provided with a package list.

...what I'm trying to say is that other people have already wrestled with many of the ideas brought up here. Drupal doesn't have to — and shouldn't — copy their solutions, but it's certainly wise to do some research.

Like houndbee, I'd be glad to talk further with anyone interested in implementing this.

coming soon to a Drupal near you

greggles's picture

Thanks, Paul Kishimoto! Great points and great summary of features!

There is actually some work on this as a PluginManager via the Summer of Code project: http://groups.drupal.org/node/10893

Please do keep track of that project and be sure to provide feedback. One note: many of the features (most) are currently out of scope. We just need to get the basic pieces of it done and done securely first. Then we can see about the rest of the ideas.

Certainly these should all be feature requests on the project eventually so that they can be planned for the future.

--
Open Prediction Markets | Drupal Dashboard

Good news

Paul Natsuo Kishimoto's picture

I agree that a lot of the things are out of scope... mainly my hope is that those 'basic pieces' are written with some forethought so they're extensible enough to cover future enhancements, without API breaks.

Looks like I'll be harassing JoshuaRogers a lot in the near future :D Thanks for the tip!

Harass me all you like!

JoshuaRogers's picture

Believe me, I read every one of the comments and suggestions about this project. I'll even help you harass me: A more recent discussion on this project is occuring at http://groups.drupal.org/node/11678. :P

Wrap a gui on drush

DanGarthwaite's picture

I use drush. I'd be happy to walk clients through a nice UI wrapper around drush.

I like debian's apt model: The server (ftp.drupal.org?) looks into all the modules and builds the dependency tree. This is then compressed and made available for download.

Drupal clients poll this file, download it if outdated, and uses it deciding what to install for project X.

So, +1 for best practices. :)

SoC 2008

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: