As part of making Drupal more visible, and its spread more measurable, this patch adds a META GENERATOR in the generated HTML, and a special HTTP header as well.
This behavior is on by default, with only the major number, and can be turned off under Administer -> Site information, or include the minor version (if you are an exhibitionist), or just "Drupal".
Before someone jumps in and shoots this down, for security reasons, or whatever, consider the following:
CMSes do it
Xaray adds the following: <meta name="Generator" content="Xaraya" />
Joomla adds the following: <meta name="Generator" content="Joomla! - Copyright (C) 2005 - 2006 Open Source Matters. All rights reserved." />
And WordPress adds the following. <meta name="generator" content="WordPress 2.5.1" />. Note the minor version, as well as patch level! And better yet, note this comment after it: <!-- Please leave for stats -->. Not sure what stats or how, but there you have it.
For the curious, this is the issue that added this feature not too long ago in Aug 2007.
Apache does it
Moreover, look at your web server headers, and see what they reveal: perhaps more than Drupal will ever reveal. Here are some examples (hint, check ServerTokens Full in your Apache configuration):
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8b mod_bwlimited/1.4
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.1 with Suhosin-Patch
PHP does it
Example: X-Powered-By: PHP/5.2.5-pl1-gentoo
Check the expose_php settings in your php.ini file!
Benefits to Drupal
1. Give Drupal visibility for those who are interested (e.g. evaluators, management consultants, technology watchers, ...etc).
2. Give Netcraft and others the means to answer the question: "how many sites are running Drupal and what versions"? They do that for Apache/IIS/others in their web servers survey, and it would only be a matter of time before they do it for CMSes. We can even contact them and give them this hint once Drupal 7 (with this patch) is released.
3. Reduce the amount of guess work needed for support (whether by the community in the issue queue or the forums, or by Drupal shops).
4. Provides an authoritative way of "fingerprinting" Drupal sites without having to go through hoops and various techniques.
But this is a security risk, you may argue. Well, if it is, then it is security by obscurity. All the Linux distros, Apache, PHP and Linux distros ship with these settings on by default. If it is good for them, it is good for us.
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | 275092-preprocess.patch | 805 bytes | damien tournoud |
| #48 | trivialfixwithtrickytest.patch | 1.87 KB | chx |
| #45 | revert_more_crap.patch | 4.87 KB | chx |
| #44 | revert_crap.patch | 1.94 KB | chx |
| #42 | fix_meta.patch | 423 bytes | chx |
Comments
Comment #1
keith.smith commentedNot a bad idea, lots of other systems do it, and it would increase exposure (a long previous issue about hiding version and fingerprinting data as a security precaution notwithstanding).
There are some minor code style issues -- comments that need to be full sentences complete with periods, and I'm not convinced, to use the classic example, that my mother would understand the form description "Choose whether your HTML should show a META tag with the GENERATOR as Drupal. You can choose whether to display the major version (e.g. "Drupal 7"), the major and minor versions (e.g. "Drupal 7.2"), no version (only "Drupal"), or nothing at all." I think descriptions like this should not only point out that you can choose -- that part is obvious -- but perhaps give some advice about why one may wish to do so.
In terms of advertising for Drupal, this is roughly equivalent to adding the Drupal banner block, which I also thought was a good move.
And there is a patch, so I'm going for code needs work.
Comment #2
dries commentedSounds useful to me.
I'm not sure I should expose this level of configuration to the user though. It seems to me like 99.9% of the users wouldn't care about this to begin with. I'd simply make it a theme thing to take it out, and hard-code a specific format. Let's make Drupal easier to use. The last thing my dad wants to do is learn about the generator-tag.
Comment #3
kbahey commentedHere is another CMS that does it.
<meta name="generator" content="Movable Type Publishing Platform 4.01" />@Dries, would this be better as a hidden variable (I mean commented out) in settings.php without a UI?
@keith.smith, if Dries approves that the UI is dumped, then most of your comments would be addressed.
Comment #4
dries commentedI'm OK with a variable, but personally, I think it is overkill still. It can be removed at the theme-level.
Let's also make sure to write a test for this.
Comment #5
kbahey commented@Dries
Unless I am missing something obvious, I don't see how a theme can override drupal_set_html_head() and drupal_set_header(). That is why it is a variable.
Anyways, the attached patch does away with the user interface entirely. There is a variable in settings.php that is commented out.
I can roll the patch for D6 and even D5 as well if this gets accepted. Just set it to needs porting and I will do it.
Comment #6
dries commentedI still think that adding a setting for this is overkill, but I'll let others comment on this.
Comment #7
kbahey commentedIf it is programmatically overridable, I agree there is no need for a variable. But I don't know of a way to do that with the two functions I mentioned. I am using those two functions because it is a theme independent way of adding the meta generator, and the only way of adding HTTP headers.
That is why I have the variable.
Comment #8
Crell commentedI am curious why #5 uses node_init() to add the generator text. Wouldn't system_init() make more sense? It doesn't really have anything to do with nodes.
I don't have any problem with the concept of the patch itself.
Comment #9
gregglesCNW: Extra newline above
function node_last_changedand I agree with Crell that this should be in system rather than node.In general, I'm +1 for the feature, but feel that the comment block in settings.php is overkill.
The two other variables without a UI in core are dev_query and allow_insecure_uploads. These have basically no documentation within core itself. If this new feature were documented in a handbook page that would seem reasonable to me.
For a themeable solution drupal_meta_generator can call a theme function, right? That would allow overriding at the theme layer.
Then those two theme_ functions return the properly formatted string. It also fits with the goal of no hard-coded html in core.
Comment #10
kbahey commented@Crell and @greggles
Thanks for the comments.
Attached is a smaller patch, and only affects one file.
Verified working even :-)
Please review ...
Comment #11
Susurrus commentedWhy is it
instead of
?
Comment #12
kbahey commentedNo good reason. Just left over code from the earlier patches.
New patch attached.
Comment #13
cburschkaInstalled the patch, but I see no HTTP header nor meta tag. Do I need to clear a cache or reinstall the site?
Edit: Gah, sorry, I missed the fact that this is done with theme functions. Theme registry rebuilt.
Comment #14
cburschkaIt's functional and adheres to code style. There is one typo in hook_theme, namely
'arguments' => array('version' => NULL,), where the last comma should be outside the parenthesis.This patch fixes the typo.
Comment #15
dries commentedI've committed this to CVS HEAD. I'm marking it 'code needs work' because it would be good to have a test case for this.
Thanks all.
Comment #16
xmacinfoIf we can turn this thing off, I'm OK with "Generator".
It's not because a few CMS advertise themselves in the HTTP headers that Drupal should do the same. Pulling security issues under the rug won't help either. With generator on, it will be a lot easier for hacker to target security holes with much more efficiency.
So, ultimatly, the decision should be made at the site admin level. We must not forget that there are a lot of corporate users using Drupal for extranet and they would want to make sure this is turned off.
Comment #17
kbahey commented@xmacinfo
In addition to other CMSes, the same argument can be said for Debian, RedHat, Ubuntu, Gentoo, Apache, PHP, ...etc. They expose info about versions, installed modules, ...etc. So why is it that they do this without any concern about security? Are they dumb or oblivious to the risks?
Since this is a theme function, it can be overridden like any other theme function with a few lines of code.
Comment #18
kbahey commentedThis is the same patch for Drupal 6, in case Dries/Gabor decide to add it to a future 6.3.
Comment #19
kbahey commentedThis is the test for HEAD for this patch.
It tests only the HTML part, and it works. I don't know of a way to test HTTP Headers.
Comment #20
kbahey commentedThis is a better test that is version independent, and has better title, group, ...etc.
Comment #21
keith.smith commentedVery cool. The only things I see are periods at the ends of a few comments at the ends of periods and consistent use of either "meta", "Meta", (or presumably, "META").
Comment #22
kbahey commentedUpdated the patch per comments.
Comment #23
dries commentedCommitted patch #22 to CVS HEAD. Thanks kbahey.
Comment #24
kbahey commentedSetting this "to be ported" for Drupal 6, in case Dries/Goba think it is a good idea (see #18).
It would help with the visibility of Drupal 6, which now has a longer time span after the extension of the code freeze.
Comment #25
xmacinfoI’m testing this new feature. Now each page have:
<meta name="Generator" content="Drupal 7 (http://drupal.org)" />Can you give me an example of the few lines of code I would need to either remove the Generator completly or
be more specific in the version number? Would we be able to display "Drupal 7.0-dev" instead of the major version number?
Comment #26
xmacinfoOverriding the HTML meta works perfectly. Please ignore previous request.
Comment #27
catchThis broke poll.test
Marking #276200 - "poll tests don't pass" postponed until this is resolved.
edit: I doubled checked, and just to confirm, the poll theming is actually broken, not just the test.
Comment #28
cburschka... I see that even with unit testing, the poll module still retains its status as the catcher of obscure regressions!
However, I must come to the defense of this issue. It is innocent of the crime. Compare:
The output of the theme call:
The page that was returned to CURL:
I accuse devel_themer, with the span-element, in the theming layer!
Comment #29
cburschkaI can confirm that after disabling devel_themer, poll.test passes. I'll open a new issue.
Comment #30
catchTest fails without theme developer for me, as does looking at a poll with my own eyes the old fashioned way.
Comment #31
cburschkaWhich tests fail for you? In my case, with theme developer enabled, only the 7 "Choice bar is themed" tests failed, and they passed when I disabled theme developer.
The poll bars don't look right, but that's a CSS problem and it is also caused by theme developer.
Comment #32
catchWhoops.
Run all tests - poll has 7 failures.
Run poll test by itself - all passes.
With or without this patch.
Of course I was running all tests on HEAD, and narrowed down to poll test when trying to find why it was breaking. Sorry.
Comment #33
lilou commentedComment #34
lilou commentedComment #35
lilou commentedoups, back to previous status ...
Comment #36
catchComment #37
jsaints commentedI can confirm that this patch breaks the block module in the block_admin_display() function and any module that tries to change the theme using $custom_theme variable.
Bug background:
1) enable two themes in theme settings
2) go to admin/build/block
3) click the local menu task to change blocks for a theme which is not the default (active) theme. For example if foo_theme is your active theme click on /admin/build/block/list/bar_theme
4) the list of blocks enable displays for the default active foo_theme, instead of the bar_theme that the user selected.
5) saved changes affect only the default theme and not the selcted theme
The block module tries to change the theme to bar_theme, but cannot because the theme() calls in system_init have already initialized the theme (I found this using var_dump(debug_backtrace());
in init_theme()). The problem comes from calling theme() functions too early in the init process. After these lines in this patch:
// Emit the META tag in the HTML HEAD section
theme('meta_generator_html', $version);
// Emit the HTTP Header too
theme('meta_generator_header', $version)
No other module can change the theme by settings the $custom_theme variable. This bug is not present in D6 where these theme() lines are not present.
Please see the discussion on the dev mailing list called "$custom_theme when does it take effect... when does it not" at http://lists-new.drupal.org/pipermail/development/2008-August/030893.html
Comment #38
kbahey commentedSetting this to CNW then.
We need to delay the call to theme() so it does not initialize the them that early.
Comment #39
catchMarking as critical since blocks admin is properly broken.
Comment #40
kbahey commentedHere is a patch to HEAD that removes calling theme() altogether, while still allowing the user to override this functionality using a variable.
Works for me, please test and review ...
Comment #41
chx commentedComment #42
chx commentedWhat I hoped can't be fixed. But this bug can...
Edit. testing instructions: enable Marvin and go to admin/build/block/list/marvin . Observe the Garland theme without patch and Marvin with the patch.
Comment #43
dries commentedOn a related note, we need a test case to verify that the $custom_theme hack works, and continues to work. Would be great if that could be part of this patch. It is the perfect test case for it, it seems.
Comment #44
chx commented#14 needs a revert and when someone has the time to write a test for the modified version as outlined in #42 then we can commit this again. It does not seem to be an easy affair.
Comment #45
chx commentedComment #46
chx commentedOf course committing the trivial fix in #42 and not demanding an almost impossible to write test is an option...
Comment #47
webchickchx and I are discussing how a test for this might be written. I think we've come up with a solution: checking the HTML for a style.css to see if it reflects the new theme that was selected.
Comment #48
chx commentedAfter some discussion with webchick the test is not that impossible after all.
Comment #49
webchickI tested chx's patch and it works, and test passes. I also tried backing out the fix, and the test correctly reports the failure of the code to work.
That makes this RTBC, so I went ahead and Ced it. Thanks!! :)
Comment #50
damien tournoud commentedReopening... the HTML header is not printed, because template_preprocess_page is called *before* system_preprocess_page. That should do it, and pass the test.
Comment #51
webchickAwesome. Thanks!
Comment #52
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #53
chx commentedI was concentrating too much on the breakage and not what was emitted here. WTF? We never, ever put anything on screen or in source that yells "Drupal" at you. Yes, fingerprinting is possible and easy but actually putting in Drupal in the source code? I dislike that, it does not mesh with us being a framework.
Comment #54
chx commentedSite information should contain the control for generator IMNSHO.
Comment #55
webchickExposing a setting for this is completely overkill. Down with settings that only 0.000000001% of sites will ever use. Feel free to make Generator Alterator module in contrib that exposes one, however.
If you strongly dislike it, there is a theme function which can be overridden. Simply return ''; and voila. No meta generator tag.
I don't see the issue.
Comment #56
xmacinfoI can confirm that this is easy to theme. :-)