Skip to content

Commit

Permalink
Merge branch 'dev' into bug/filter_out_tso_messages_on_success
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarcaramo committed Nov 2, 2023
2 parents e8fe0f6 + e8b82cf commit 92b5885
Show file tree
Hide file tree
Showing 41 changed files with 1,427 additions and 20 deletions.
20 changes: 19 additions & 1 deletion pyracf/common/irrsmo00.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ typedef struct {
char str[8];
} VarStr_T;

// This function changes any null character not preceded by '>' to a blank character.
// This is a workaround for an issue where the profile data embedded in response xml
// returned by IRROSMO00 sometimes includes null characters instead of properly
// encoded text, which causes the returned xml to be truncated.
void null_byte_fix(char* str, unsigned int str_len) {
for (int i = 1; i < str_len; i++){
if (str[i] == 0) {
if (str[i-1] == 0x6E) {
return;
}
else {
str[i] = 0x40;
}
}
}
}

static PyObject* call_irrsmo00(PyObject* self, PyObject* args, PyObject *kwargs) {
const unsigned int xml_len;
const unsigned int input_opts;
Expand All @@ -30,7 +47,7 @@ static PyObject* call_irrsmo00(PyObject* self, PyObject* args, PyObject *kwargs)
VarStr_T userid = { 0, {0}};
unsigned int alet = 0;
unsigned int acee = 0;
char rsp[BUFFER_SIZE+1];
unsigned char rsp[BUFFER_SIZE+1];
memset(rsp, 0, BUFFER_SIZE);
unsigned int saf_rc=0, racf_rc=0, racf_rsn=0;
unsigned int num_parms=17, fn=1, opts = input_opts, rsp_len = sizeof(rsp)-1;
Expand All @@ -55,6 +72,7 @@ static PyObject* call_irrsmo00(PyObject* self, PyObject* args, PyObject *kwargs)
rsp
);

null_byte_fix(rsp,rsp_len);
return Py_BuildValue("y", rsp);
}

Expand Down
28 changes: 20 additions & 8 deletions pyracf/data_set/data_set_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,18 @@ def add(
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)
try:
self.extract(data_set, volume=volume, generic=generic)
profile = self.extract(
data_set, volume=volume, generic=generic, profile_only=True
)
if self._get_field(profile, "base", "name") == data_set.lower():
raise AddOperationError(data_set, self._profile_type)
except SecurityRequestError as exception:
if not exception.contains_error_message(self._profile_type, "ICH35003I"):
raise exception
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)
raise AddOperationError(data_set, self._profile_type)
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request)
return self._make_request(data_set_request)

def alter(
self,
Expand All @@ -127,11 +130,20 @@ def alter(
volume: Union[str, None] = None,
generic: bool = False,
) -> Union[dict, bytes]:
"""Alter an existing data set profile."""
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request, alter=True)
return self._make_request(data_set_request, irrsmo00_precheck=True)
try:
self.extract(data_set)
profile = self.extract(
data_set, volume=volume, generic=generic, profile_only=True
)
except SecurityRequestError:
raise AlterOperationError(data_set, self._profile_type)
"""Alter an existing data set profile."""
if not self._get_field(profile, "base", "name") == data_set.lower():
raise AlterOperationError(data_set, self._profile_type)
self._build_segment_dictionaries(traits)
data_set_request = DataSetRequest(data_set, "set", volume, generic)
self._build_xml_segments(data_set_request, alter=True)
Expand Down
5 changes: 5 additions & 0 deletions pyracf/group/group_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def add(self, group: str, traits: dict = {}) -> Union[dict, bytes]:

def alter(self, group: str, traits: dict) -> Union[dict, bytes]:
"""Alter an existing group."""
if self._generate_requests_only:
self._build_segment_dictionaries(traits)
group_request = GroupRequest(group, "set")
self._build_xml_segments(group_request, alter=True)
return self._make_request(group_request, irrsmo00_precheck=True)
try:
self.extract(group)
except SecurityRequestError:
Expand Down
Loading

0 comments on commit 92b5885

Please sign in to comment.