Similar to the fix for the reason timestamp, the reason user
should also be compared when creating sinfo -R and sinfo -Rl output,
or else incorrect usernames could end up in output if everything
else matches.
---
 src/sinfo/opts.c  |    4 ++++
 src/sinfo/sinfo.c |    6 ++++++
 src/sinfo/sinfo.h |    1 +
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c
index b1fc5f2..c0db95f 100644
--- a/src/sinfo/opts.c
+++ b/src/sinfo/opts.c
@@ -647,11 +647,13 @@ _parse_format( char* format )
                                               right_justify,
                                               suffix );
                } else if (field[0] == 'u') {
+                       params.match_flags.reason_user_flag = true;
                        format_add_user( params.format_list,
                                        field_size,
                                        right_justify,
                                        suffix );
                } else if (field[0] == 'U') {
+                       params.match_flags.reason_user_flag = true;
                        format_add_user_long( params.format_list,
                                              field_size,
                                              right_justify,
@@ -814,6 +816,8 @@ void _print_options( void )
                        "true" : "false");
        printf("reason_timestamp_flag = %s\n",
                        params.match_flags.reason_timestamp_flag ?  "true" : 
"false");
+       printf("reason_user_flag = %s\n",
+                       params.match_flags.reason_user_flag ?  "true" : 
"false");
        printf("root_flag       = %s\n", params.match_flags.root_flag ?
                        "true" : "false");
        printf("share_flag      = %s\n", params.match_flags.share_flag ?
diff --git a/src/sinfo/sinfo.c b/src/sinfo/sinfo.c
index c054e26..fc527ea 100644
--- a/src/sinfo/sinfo.c
+++ b/src/sinfo/sinfo.c
@@ -519,6 +519,12 @@ static bool _match_node_data(sinfo_data_t *sinfo_ptr, 
node_info_t *node_ptr)
            (node_ptr->reason_time != sinfo_ptr->reason_time))
                return false;
 
+       if (sinfo_ptr->nodes &&
+           params.match_flags.reason_user_flag &&
+           node_ptr->reason_uid != sinfo_ptr->reason_uid) {
+               return false;
+       }
+
        if (params.match_flags.state_flag) {
                char *state1, *state2;
                state1 = node_state_string(node_ptr->node_state);
diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h
index e0cdb2c..af54634 100644
--- a/src/sinfo/sinfo.h
+++ b/src/sinfo/sinfo.h
@@ -142,6 +142,7 @@ struct sinfo_match_flags {
        bool state_flag;
        bool weight_flag;
        bool reason_timestamp_flag;
+       bool reason_user_flag;
 };
 
 /* Input parameters */
-- 
1.7.1

Reply via email to