Add support for yum

Bug #769948 reported by Maciej Małecki
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zeitgeist Data-Sources
In Progress
Wishlist
Maciej Małecki

Bug Description

I'm not sure if adding this to Zeitgeist makes sense, but sometimes I would like to see what package (and when) I've installed without opening PackageKit and browsing logs.
If Zeitgeist Data-Providers team also would like this in Zeitgeist, I'm willing to write a plugin.

Revision history for this message
Seif Lotfy (seif) wrote : Re: [Bug 769948] [NEW] Add support for yum

This would be AMAZING we will need to update the ontology though. But feel
free to start...
Cheers
Seif

2011/4/24 Maciej Małecki <email address hidden>

> Public bug reported:
>
> I'm not sure if adding this to Zeitgeist makes sense, but sometimes I would
> like to see what package (and when) I've installed without opening
> PackageKit and browsing logs.
> If Zeitgeist Data-Providers team also would like this in Zeitgeist, I'm
> willing to write a plugin.
>
> ** Affects: zeitgeist-dataproviders
> Importance: Undecided
> Status: New
>
>
> ** Tags: packagekit wishlist yum
>
> --
> You received this bug notification because you are subscribed to The
> Zeitgeist Project.
> https://bugs.launchpad.net/bugs/769948
>
> Title:
> Add support for yum
>
> Status in Zeitgeist Data-Providers:
> New
>
> Bug description:
> I'm not sure if adding this to Zeitgeist makes sense, but sometimes I
> would like to see what package (and when) I've installed without opening
> PackageKit and browsing logs.
> If Zeitgeist Data-Providers team also would like this in Zeitgeist, I'm
> willing to write a plugin.
>

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Maciej,

You have an idea how of yum works internally, can any script be loaded? Means extensions support. If it is there, then it's a great thing.

Please let us know

Revision history for this message
Maciej Małecki (maciej-malecki) wrote :

There's an API. Plugin gets "inserted" into process of installing packages. It is described here: http://yum.baseurl.org/wiki/WritingYumPlugins
There is also another way ( http://mo.morsi.org/blog/node/220 ), but it would need to be called with some interval, gather information about all installed packages and compare them with previous state, which isn't performance-wise.
Though there may be another way (with better performance, easier, etc.). If there is, please point it out.

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Maciej,
I saw your yum branch. Will merge it once I download Fedora and improve that branch a bit more. BTW which version of Fedora should I install and which version? The latest one in development? F15? Link to download that exact one?

Revision history for this message
Maciej Małecki (maciej-malecki) wrote :

This branch is not done yet (it does nothing besides installing this "plugin" now), I think I will get it done in 2 days or so (I will issue a merge request then).
I'm currently using Fedora 15 and Fedora 14 (though tomorrow I'm switching all hosts to Fedora 15).
Fedora 15 Beta is here: http://fedoraproject.org/get-prerelease?wkanF15b
Don't worry about "beta" thing, it's really stable and looks great (and you will be on the cutting-edge of Linux development, which is really cool).

Revision history for this message
Maciej Małecki (maciej-malecki) wrote :

Oops. Now I'm facing a problem which I haven't thought about before and which I haven't noticed before latest commit.
Zeitgeist-daemon is running with privileges of current user, whilst yum needs root privileges to run, so yum plugin tries to talk to nonexistent zeitgeist-daemon in context of root user. As far as I see, this daemon is then started, however it uses database in /root/.local/share/zeitgeist. I can see commited events when starting GAJ as root, but not as regular user.
Now, I have no idea what to do with this. Basic possibilities are:
 * change zeitgeist-daemon behaviour to make him create his database in a location which regular user can read and allow daemons running in user-space to transparently read it and serve it's content to clients,
 * make zeitgeist-daemon running as root to proxy all the communication to all daemons running in contexts of non-root users,
 * do the magic and find out somehow who started current sudo or su process and connect to his zeitgeist-daemon (is it even possible?).

Maybe I should report new bug regarding this situation outside zeitgeist-dataprovides? I don't know if zeitgeist-daemon guys observe bugs reported here.

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

I think this is not much of a problem provided the user uses "sudo" instead "su".
Just try
$ sudo ls ~

You will see that it is outputs the folders of your directory and not root's
When you use sudo you just get superuser privileges and your environment variable are not changed.

Revision history for this message
Maciej Małecki (maciej-malecki) wrote :

For ls it's true, because ~ is expanded by bash. Python works in a bit different way:
    $ sudo python
    >>> import os
    >>> os.getenv("HOME")
    '/root'
    >>> import os.path
    >>> os.path.expanduser("~")
    '/root'

Yes, there are few environment variables preserved (like USERNAME), but sudo changes your working environment (you can easily check: compare `env` output with `sudo env` output).

So, for zeitgeist-daemon running as root it's home directory is /root and we should decide what to do in this kind of a situation. Should I report this directly to Zeitgeist and see if daemon guys can figure something out?

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote : Re: [Bug 769948] Re: Add support for yum

Just click on also affects and set it to zeitgeist. Seif and rainct should
decide now as rest are not so free for zg work
On 27-Apr-2011 1:21 AM, "Maciej Małecki" <email address hidden> wrote:
>
> For ls it's true, because ~ is expanded by bash. Python works in a bit
different way:
> $ sudo python
> >>> import os
> >>> os.getenv("HOME")
> '/root'
> >>> import os.path
> >>> os.path.expanduser("~")
> '/root'
>
> Yes, there are few environment variables preserved (like USERNAME), but
> sudo changes your working environment (you can easily check: compare
> `env` output with `sudo env` output).
>
> So, for zeitgeist-daemon running as root it's home directory is /root
> and we should decide what to do in this kind of a situation. Should I
> report this directly to Zeitgeist and see if daemon guys can figure
> something out?
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/769948
>
> Title:
> Add support for yum
>
> Status in Zeitgeist Data-Providers:
> New
>
> Bug description:
> I'm not sure if adding this to Zeitgeist makes sense, but sometimes I
would like to see what package (and when) I've installed without opening
PackageKit and browsing logs.
> If Zeitgeist Data-Providers team also would like this in Zeitgeist, I'm
willing to write a plugin.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/zeitgeist-dataproviders/+bug/769948/+subscribe

Revision history for this message
Siegfried Gevatter (rainct) wrote :

Maybe yum logs its actions to some file which can be read by users (and so parsed by zeitgeist-datahub)?

Revision history for this message
Maciej Małecki (maciej-malecki) wrote :

Sorry I could get back to it so late.

I've figured out a way to handle the problem with root privileges (at least, most cases).
Plugin now forks right after collecting data. Fork tries to find out who ran it really (by checking environment variables) and sets it's UID and GID like he was that user. This one works (I'm able to see events in GAJ as regular user).
Only case when it doesn't work is when yum is being executed with `su -` - whole environment gets replaced - any ideas how to fix it?

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) wrote :

Maciej,
I think the first use case is enough. That would suffice. We can think about it later. There are some cases in which we are helpless. If the whole environment gets replaced, then I cant find any way for the script to know which user actually initiated it.

I would suggest you to finish the first use-case in the branch and send a merge request. if you have any problems in integrating your yum datasource with the build system , contact me on IRC

Changed in zeitgeist-datasources:
assignee: nobody → Maciej Małecki (maciej-malecki)
importance: Undecided → Wishlist
status: New → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.