The documentation for drush cron says:
You should set up crontab to run your cron tasks as the same user that runs the web server; for example, if you run your webserver as the user www-data:
I wrote a wrapper drush command to do this. In my drush_hook_COMMAND, I call
system('sudo -i -u www-data /usr/bin/drush --uri=http://BLAH --root=BLAH cron');
This works in almost all ways. However it does not correctly check for updates. On my drupal status page I get
There was a problem checking available updates for Drupal...
I've tried using drush_shell_exec instead of system, just the same. However if I do it via drush eval, it does work:
drush eval "system('sudo -i -u www-data /usr/bin/drush --uri=http://BLAH --root=BLAH cron');"
So I'm completely baffled. Any idea what could be different between eval and the command hook?