@@ -1031,93 +1031,101 @@ static bool wbinfo_sid_to_gid(const char *sid_str)
1031
1031
1032
1032
static bool wbinfo_sids_to_unix_ids (const char * arg )
1033
1033
{
1034
- char sidstr [WBC_SID_STRING_BUFLEN ];
1034
+ TALLOC_CTX * frame = talloc_stackframe ();
1035
+ char * sidstr = NULL ;
1035
1036
struct wbcDomainSid * sids ;
1036
1037
struct wbcUnixId * unix_ids ;
1037
1038
int i , num_sids ;
1038
1039
const char * p ;
1039
1040
wbcErr wbc_status ;
1040
-
1041
+ bool ret = false;
1041
1042
1042
1043
num_sids = 0 ;
1043
1044
sids = NULL ;
1044
1045
p = arg ;
1045
1046
1046
- while (next_token (& p , sidstr , LIST_SEP , sizeof (sidstr ))) {
1047
- sids = talloc_realloc (talloc_tos (), sids , struct wbcDomainSid ,
1048
- num_sids + 1 );
1047
+ while (next_token_talloc (frame , & p , & sidstr , LIST_SEP )) {
1048
+ sids = talloc_realloc (frame ,
1049
+ sids ,
1050
+ struct wbcDomainSid ,
1051
+ num_sids + 1 );
1049
1052
if (sids == NULL ) {
1050
1053
d_fprintf (stderr , "talloc failed\n" );
1051
- return false ;
1054
+ goto fail ;
1052
1055
}
1053
1056
wbc_status = wbcStringToSid (sidstr , & sids [num_sids ]);
1054
1057
if (!WBC_ERROR_IS_OK (wbc_status )) {
1055
1058
d_fprintf (stderr , "wbcSidToString(%s) failed: %s\n" ,
1056
1059
sidstr , wbcErrorString (wbc_status ));
1057
- TALLOC_FREE (sids );
1058
- return false;
1060
+ goto fail ;
1059
1061
}
1062
+ TALLOC_FREE (sidstr );
1060
1063
num_sids += 1 ;
1061
1064
}
1062
1065
1063
- unix_ids = talloc_array (talloc_tos () , struct wbcUnixId , num_sids );
1066
+ unix_ids = talloc_array (frame , struct wbcUnixId , num_sids );
1064
1067
if (unix_ids == NULL ) {
1065
- TALLOC_FREE (sids );
1066
- return false;
1068
+ goto fail ;
1067
1069
}
1068
1070
1069
1071
wbc_status = wbcSidsToUnixIds (sids , num_sids , unix_ids );
1070
1072
if (!WBC_ERROR_IS_OK (wbc_status )) {
1071
1073
d_fprintf (stderr , "wbcSidsToUnixIds failed: %s\n" ,
1072
1074
wbcErrorString (wbc_status ));
1073
- TALLOC_FREE (sids );
1074
- return false;
1075
+ goto fail ;
1075
1076
}
1076
1077
1077
1078
for (i = 0 ; i < num_sids ; i ++ ) {
1079
+ fstring sidbuf ;
1078
1080
1079
- wbcSidToStringBuf (& sids [i ], sidstr , sizeof (sidstr ));
1081
+ wbcSidToStringBuf (& sids [i ], sidbuf , sizeof (sidbuf ));
1080
1082
1081
1083
switch (unix_ids [i ].type ) {
1082
1084
case WBC_ID_TYPE_UID :
1083
- d_printf ("%s -> uid %d\n" , sidstr , unix_ids [i ].id .uid );
1085
+ d_printf ("%s -> uid %d\n" , sidbuf , unix_ids [i ].id .uid );
1084
1086
break ;
1085
1087
case WBC_ID_TYPE_GID :
1086
- d_printf ("%s -> gid %d\n" , sidstr , unix_ids [i ].id .gid );
1088
+ d_printf ("%s -> gid %d\n" , sidbuf , unix_ids [i ].id .gid );
1087
1089
break ;
1088
1090
case WBC_ID_TYPE_BOTH :
1089
- d_printf ("%s -> uid/gid %d\n" , sidstr , unix_ids [i ].id .uid );
1091
+ d_printf ("%s -> uid/gid %d\n" ,
1092
+ sidbuf ,
1093
+ unix_ids [i ].id .uid );
1090
1094
break ;
1091
1095
default :
1092
- d_printf ("%s -> unmapped\n" , sidstr );
1096
+ d_printf ("%s -> unmapped\n" , sidbuf );
1093
1097
break ;
1094
1098
}
1095
1099
}
1096
1100
1097
- TALLOC_FREE ( sids ) ;
1098
- TALLOC_FREE ( unix_ids );
1099
-
1100
- return true ;
1101
+ ret = true ;
1102
+ fail :
1103
+ TALLOC_FREE ( frame );
1104
+ return ret ;
1101
1105
}
1102
1106
1103
1107
static bool wbinfo_xids_to_sids (const char * arg )
1104
1108
{
1105
- fstring idstr ;
1109
+ TALLOC_CTX * frame = talloc_stackframe ();
1110
+ char * idstr = NULL ;
1106
1111
struct wbcUnixId * xids = NULL ;
1107
1112
struct wbcDomainSid * sids ;
1108
1113
wbcErr wbc_status ;
1109
1114
int num_xids = 0 ;
1110
1115
const char * p ;
1111
1116
int i ;
1117
+ bool ret = false;
1112
1118
1113
1119
p = arg ;
1114
1120
1115
- while (next_token (& p , idstr , LIST_SEP , sizeof (idstr ))) {
1116
- xids = talloc_realloc (talloc_tos (), xids , struct wbcUnixId ,
1117
- num_xids + 1 );
1121
+ while (next_token_talloc (frame , & p , & idstr , LIST_SEP )) {
1122
+ xids = talloc_realloc (xids ,
1123
+ xids ,
1124
+ struct wbcUnixId ,
1125
+ num_xids + 1 );
1118
1126
if (xids == NULL ) {
1119
1127
d_fprintf (stderr , "talloc failed\n" );
1120
- return false ;
1128
+ goto fail ;
1121
1129
}
1122
1130
1123
1131
switch (idstr [0 ]) {
@@ -1135,26 +1143,23 @@ static bool wbinfo_xids_to_sids(const char *arg)
1135
1143
break ;
1136
1144
default :
1137
1145
d_fprintf (stderr , "%s is an invalid id\n" , idstr );
1138
- TALLOC_FREE (xids );
1139
- return false;
1146
+ goto fail ;
1140
1147
}
1148
+ TALLOC_FREE (idstr );
1141
1149
num_xids += 1 ;
1142
1150
}
1143
1151
1144
- sids = talloc_array (talloc_tos () , struct wbcDomainSid , num_xids );
1152
+ sids = talloc_array (frame , struct wbcDomainSid , num_xids );
1145
1153
if (sids == NULL ) {
1146
1154
d_fprintf (stderr , "talloc failed\n" );
1147
- TALLOC_FREE (xids );
1148
- return false;
1155
+ goto fail ;
1149
1156
}
1150
1157
1151
1158
wbc_status = wbcUnixIdsToSids (xids , num_xids , sids );
1152
1159
if (!WBC_ERROR_IS_OK (wbc_status )) {
1153
1160
d_fprintf (stderr , "wbcUnixIdsToSids failed: %s\n" ,
1154
1161
wbcErrorString (wbc_status ));
1155
- TALLOC_FREE (sids );
1156
- TALLOC_FREE (xids );
1157
- return false;
1162
+ goto fail ;
1158
1163
}
1159
1164
1160
1165
for (i = 0 ; i < num_xids ; i ++ ) {
@@ -1169,7 +1174,10 @@ static bool wbinfo_xids_to_sids(const char *arg)
1169
1174
d_printf ("%s\n" , str );
1170
1175
}
1171
1176
1172
- return true;
1177
+ ret = true;
1178
+ fail :
1179
+ TALLOC_FREE (frame );
1180
+ return ret ;
1173
1181
}
1174
1182
1175
1183
static bool wbinfo_allocate_uid (void )
@@ -1502,34 +1510,37 @@ static bool wbinfo_lookuprids(const char *domain, const char *arg)
1502
1510
1503
1511
static bool wbinfo_lookup_sids (const char * arg )
1504
1512
{
1505
- char sidstr [WBC_SID_STRING_BUFLEN ];
1513
+ TALLOC_CTX * frame = talloc_stackframe ();
1514
+ char * sidstr = NULL ;
1506
1515
struct wbcDomainSid * sids ;
1507
1516
struct wbcDomainInfo * domains ;
1508
1517
struct wbcTranslatedName * names ;
1509
1518
int num_domains ;
1510
1519
int i , num_sids ;
1511
1520
const char * p ;
1512
1521
wbcErr wbc_status ;
1513
-
1522
+ bool ret ;
1514
1523
1515
1524
num_sids = 0 ;
1516
1525
sids = NULL ;
1517
1526
p = arg ;
1518
1527
1519
- while (next_token (& p , sidstr , LIST_SEP , sizeof (sidstr ))) {
1520
- sids = talloc_realloc (talloc_tos (), sids , struct wbcDomainSid ,
1521
- num_sids + 1 );
1528
+ while (next_token_talloc (frame , & p , & sidstr , LIST_SEP )) {
1529
+ sids = talloc_realloc (frame ,
1530
+ sids ,
1531
+ struct wbcDomainSid ,
1532
+ num_sids + 1 );
1522
1533
if (sids == NULL ) {
1523
1534
d_fprintf (stderr , "talloc failed\n" );
1524
- return false ;
1535
+ goto fail ;
1525
1536
}
1526
1537
wbc_status = wbcStringToSid (sidstr , & sids [num_sids ]);
1527
1538
if (!WBC_ERROR_IS_OK (wbc_status )) {
1528
1539
d_fprintf (stderr , "wbcSidToString(%s) failed: %s\n" ,
1529
1540
sidstr , wbcErrorString (wbc_status ));
1530
- TALLOC_FREE (sids );
1531
- return false;
1541
+ goto fail ;
1532
1542
}
1543
+ TALLOC_FREE (sidstr );
1533
1544
num_sids += 1 ;
1534
1545
}
1535
1546
@@ -1538,8 +1549,7 @@ static bool wbinfo_lookup_sids(const char *arg)
1538
1549
if (!WBC_ERROR_IS_OK (wbc_status )) {
1539
1550
d_fprintf (stderr , "wbcLookupSids failed: %s\n" ,
1540
1551
wbcErrorString (wbc_status ));
1541
- TALLOC_FREE (sids );
1542
- return false;
1552
+ goto fail ;
1543
1553
}
1544
1554
1545
1555
for (i = 0 ; i < num_sids ; i ++ ) {
@@ -1568,7 +1578,11 @@ static bool wbinfo_lookup_sids(const char *arg)
1568
1578
}
1569
1579
wbcFreeMemory (names );
1570
1580
wbcFreeMemory (domains );
1571
- return true;
1581
+
1582
+ ret = true;
1583
+ fail :
1584
+ TALLOC_FREE (frame );
1585
+ return ret ;
1572
1586
}
1573
1587
1574
1588
/* Convert string to sid */
0 commit comments