Bug 1162840

Summary: channel.software.listSusbcribedSystems uses Hibernate query that does not take into account Trusted Relationships
Product: [Community] Spacewalk Reporter: Stephen Herr <sherr>
Component: APIAssignee: Stephen Herr <sherr>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: high Docs Contact:
Priority: urgent    
Version: 2.2CC: cperry, pgervase, satqe-list, tpapaioa, xdmoon
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: spacewalk-java-2.3.76 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1149829 Environment:
Last Closed: 2015-04-14 19:03:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 924189, 1140341, 1207293    

Description Stephen Herr 2014-11-11 20:14:43 UTC
+++ This bug was initially created as a clone of Bug #1149829 +++

Description of problem:
When you have a suborg using a channel shared by trust from the parent org, you're not able to use the channel.software.listSubscribedSystems api method.

Version-Release number of selected component (if applicable):
spacewalk-java-2.0.2-85.el6sat.noarch

How reproducible:
100%

Steps to Reproduce:
1. In the parent org, create a sub org
2. In the parent org, create a trust to the sub org
3. In the sub org, register a system and give it the channel shared by trust from the parent
4. Use the api script to try to list it:
$ perl 00920875.pl 
channel id: 101 and label: rhel-x86_64-server-5
channel id: 102 and label: rhel-x86_64-server-6
channel id: 112 and label: rhel-i386-server-5.5
channel id: 109 and label: rhel-i386-as-4
channel id: 110 and label: clone-rhel-x86_64-server-6
channel id: 111 and label: mycustomchan
channel id: 113 and label: parentorgchannel
Fault returned from XML RPC Server, fault code -210: redstone.xmlrpc.XmlRpcFault: No such channel: parentorgchannel
$ cat 00920875.pl
#!/usr/bin/perl
use Frontier::Client;

my $HOST = 'spacewalk.example.com';
my $user = 'suborgadmin';
my $pass = 'redhat';
my $chanlabel = 'parentorgchannel';

my $client = new Frontier::Client(url => "http://$HOST/rpc/api");#, debug=>1);
my $session = $client->call('auth.login',$user, $pass);

my $channels = $client->call('channel.listAllChannels', $session);

# dereference (@) the perl array to loop
for (@{$channels}) {
      print "channel id: " . $_->{'id'};
      print " and label: " . $_->{'label'} . "\n";
}


my $systems = $client->call('channel.software.listSubscribedSystems', $session, $chanlabel);
 
# dereference (@) the perl array to loop
for (@{$systems}) {
  print "system id: " . $_->{'id'};
  print " and name: " . $_->{'name'} . "\n";
}

$client->call('auth.logout', $session);   

Actual results:
Fault returned from XML RPC Server, fault code -210: redstone.xmlrpc.XmlRpcFault: No such channel: parentorgchannel

Expected results:
To have the system returned like
system id: 1000010002 and name: gss-rhel6u3-64.usersys.redhat.com

Additional info:

--- Additional comment from Stephen Herr on 2014-11-11 14:33:38 EST ---

This error exactly as described (for listSubscribedSystems) is fixed already in Spacewalk 2.2, however the same problem still exists for 

channel.software.isUserSubscribable
channel.software.isUserManageable
channel.software.setGloballySubscribable
channel.software.addPackages
channel.software.removePackages
channel.software.clone
channel.software.subscribeSystem (deprecated)

Obviously the ones that involve modifying the channel should return an exception if the channel is not owned by the org of the logged in user, but it should make sense and not be a "no such channel" error.

Comment 1 Stephen Herr 2014-11-11 20:20:29 UTC
Committing to Spacewalk master:
655808b14be60c172f2fae12546846fb33759251

Comment 2 Grant Gainey 2015-03-23 16:59:17 UTC
Moving bugs to ON_QA as we move to release Spacewalk 2.3

Comment 3 Grant Gainey 2015-04-14 19:03:31 UTC
Spacewalk 2.3 has been released. See

https://fedorahosted.org/spacewalk/wiki/ReleaseNotes23

Comment 4 Gennadii Altukhov 2016-03-16 09:44:57 UTC
*** Bug 1140340 has been marked as a duplicate of this bug. ***

Comment 5 Jan Dobes 2016-03-21 12:15:57 UTC
*** Bug 1140341 has been marked as a duplicate of this bug. ***