Changeset 9222
- Timestamp:
- 03/07/12 17:53:55 (15 months ago)
- Location:
- trunk
- Files:
-
- 6 modified
-
include/pvfs2-debug.h (modified) (1 diff)
-
include/pvfs2-types.h (modified) (1 diff)
-
src/apps/admin/pvfs2-gencred.c (modified) (19 diffs)
-
src/common/mgmt/pint-worker-per-op.c (modified) (3 diffs)
-
src/common/mgmt/pint-worker-threaded-queues.c (modified) (3 diffs)
-
src/common/misc/pvfs2-util.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/pvfs2-debug.h
r9123 r9222 217 217 { "bstream", GOSSIP_BSTREAM_DEBUG }, 218 218 /* Debug trove in direct io mode */ 219 {"directio", GOSSIP_DIRECTIO_DEBUG}, 219 { "directio", GOSSIP_DIRECTIO_DEBUG }, 220 /* Debug direct io thread management */ 221 { "mgmt", GOSSIP_MGMT_DEBUG }, 220 222 /* Debug mirroring process */ 221 { "mirror",GOSSIP_MIRROR_DEBUG},223 { "mirror",GOSSIP_MIRROR_DEBUG }, 222 224 /* Windows client */ 223 { "win_client", GOSSIP_WIN_CLIENT_DEBUG},225 { "win_client", GOSSIP_WIN_CLIENT_DEBUG }, 224 226 /* Debug robust security code */ 225 { "security", GOSSIP_SECURITY_DEBUG},227 { "security", GOSSIP_SECURITY_DEBUG }, 226 228 /* Client User Interface */ 227 { "usrint", GOSSIP_USRINT_DEBUG},229 { "usrint", GOSSIP_USRINT_DEBUG }, 228 230 /* Everything except the periodic events. Useful for debugging */ 229 231 { "verbose", -
trunk/include/pvfs2-types.h
r9170 r9222 911 911 abs(error))) & ~mask)]; \ 912 912 } \ 913 return ret; \913 return ret; \ 914 914 } \ 915 915 PVFS_error PVFS_errno_to_error(int err) \ 916 916 { \ 917 917 PVFS_error e = 0; \ 918 \918 \ 919 919 for(; e < PVFS_ERRNO_MAX; ++e) \ 920 920 { \ 921 921 if(PINT_errno_mapping[e] == err) \ 922 922 { \ 923 return e ;\923 return e | PVFS_ERROR_BIT; \ 924 924 } \ 925 925 } \ 926 return 0;\926 return err; \ 927 927 } \ 928 928 DECLARE_ERRNO_MAPPING() -
trunk/src/apps/admin/pvfs2-gencred.c
r9170 r9222 61 61 if (cnt == -1) 62 62 { 63 return -1;63 return errno; 64 64 } 65 65 } … … 89 89 optarg); 90 90 usage(); 91 return E XIT_FAILURE;91 return EINVAL; 92 92 } 93 93 break; … … 98 98 default: 99 99 usage(); 100 return E XIT_FAILURE;100 return EINVAL; 101 101 } 102 102 } … … 117 117 if (issuer == NULL) 118 118 { 119 return E XIT_FAILURE;119 return ENOMEM; 120 120 } 121 121 /* issuer field for clients is prefixed with "C:" */ … … 132 132 { 133 133 free(issuer); 134 return E XIT_FAILURE;134 return ENOMEM; 135 135 } 136 136 for (i = 0; i < ngroups; i++) … … 158 158 if (keyfile == NULL) 159 159 { 160 int err = errno; 160 161 perror(keypath); 161 return EXIT_FAILURE;162 return err; 162 163 } 163 164 … … 165 166 if (ret == -1) 166 167 { 168 int err = errno; 167 169 perror("stat"); 168 170 fclose(keyfile); 169 return EXIT_FAILURE;171 return err; 170 172 } 171 173 if (stats.st_mode & (S_IROTH | S_IWOTH)) … … 180 182 ERR_print_errors_fp(stderr); 181 183 fclose(keyfile); 182 return E XIT_FAILURE;184 return ENODATA; 183 185 } 184 186 … … 190 192 { 191 193 EVP_PKEY_free(privkey); 192 return E XIT_FAILURE;194 return ENOMEM; 193 195 } 194 196 … … 217 219 EVP_MD_CTX_cleanup(&mdctx); 218 220 EVP_PKEY_free(privkey); 219 return E XIT_FAILURE;221 return ENODATA; 220 222 } 221 223 ret = EVP_SignFinal(&mdctx, cred->signature, &cred->sig_size, privkey); … … 226 228 EVP_MD_CTX_cleanup(&mdctx); 227 229 EVP_PKEY_free(privkey); 228 return E XIT_FAILURE;230 return ENODATA; 229 231 } 230 232 … … 259 261 { 260 262 fputs("error: stdout is a tty\n", stderr); 261 return E XIT_FAILURE;263 return EIO; 262 264 } 263 265 264 266 encode_PVFS_credential(&pptr, cred); 265 267 ret = safe_write(STDOUT_FILENO, buf, sizeof(buf)); 266 if (ret == -1)267 { 268 if (ret) 269 { 268 270 perror("write"); 269 return EXIT_FAILURE;271 return ret; 270 272 } 271 273 … … 326 328 fprintf(stderr, "unknown user -- %s\n", opts.user); 327 329 } 328 return E XIT_FAILURE;330 return EINVAL; 329 331 } 330 332 … … 361 363 fprintf(stderr, "unknown group -- %s\n", opts.group); 362 364 } 363 return E XIT_FAILURE;365 return EINVAL; 364 366 } 365 367 … … 368 370 fprintf(stderr, "error: only %s and root can generate a credential " 369 371 "for %s\n", pwd->pw_name, pwd->pw_name); 370 return E XIT_FAILURE;372 return EPERM; 371 373 } 372 374 … … 375 377 fprintf(stderr, "error: cannot generate a credential for group %s: " 376 378 "Permission denied\n", grp->gr_name); 377 return E XIT_FAILURE;379 return EPERM; 378 380 } 379 381 … … 386 388 fprintf(stderr, "error: unable to get group list for user %s\n", 387 389 pwd->pw_name); 388 return E XIT_FAILURE;390 return ENOENT; 389 391 } 390 392 if (groups[0] != grp->gr_gid) … … 401 403 if (ngroups == -1) 402 404 { 405 int err = errno; 403 406 fprintf(stderr, "error: unable to get group list for user %s: %s\n", 404 407 pwd->pw_name, strerror(errno)); 405 return EXIT_FAILURE;408 return err; 406 409 } 407 410 … … 436 439 free(credential.issuer); 437 440 free(credential.group_array); 441 438 442 return EXIT_SUCCESS; 439 443 } -
trunk/src/common/mgmt/pint-worker-per-op.c
r7450 r9222 80 80 if(ret != 0) 81 81 { 82 return PVFS_get_errno_mapping(ret);82 return -PVFS_errno_to_error(ret); 83 83 } 84 84 … … 90 90 { 91 91 pthread_attr_destroy(&attr); 92 return PVFS_get_errno_mapping(ret);92 return -PVFS_errno_to_error(ret); 93 93 } 94 94 … … 100 100 if(ret != 0) 101 101 { 102 return PVFS_errno_to_error(ret);102 return -PVFS_errno_to_error(ret); 103 103 } 104 104 -
trunk/src/common/mgmt/pint-worker-threaded-queues.c
r8925 r9222 74 74 free(w->threads); 75 75 gen_cond_destroy(&w->cond); 76 goto exit; 76 77 } 77 78 gossip_debug(GOSSIP_MGMT_DEBUG,"%s:thread_id %d:thread #%d.\n" … … 529 530 ret = pthread_create(&tentry->thread_id, NULL, 530 531 PINT_worker_queues_thread_function, tentry); 531 if(ret <0)532 if(ret != 0) 532 533 { 533 534 /* convert to PVFS error */ 534 return PVFS_errno_to_error(ret);535 return -PVFS_errno_to_error(ret); 535 536 } 536 537 return 0; … … 554 555 555 556 ret = pthread_join(tentry->thread_id, &ptr); 556 if(ret <0)557 if(ret != 0) 557 558 { 558 559 return PVFS_errno_to_error(ret); -
trunk/src/common/misc/pvfs2-util.c
r9177 r9222 183 183 struct sigaction newsa, oldsa; 184 184 pid_t pid; 185 int filedes[2] ;185 int filedes[2], errordes[2]; 186 186 int ret; 187 187 … … 195 195 sigaction(SIGCHLD, &newsa, &oldsa); 196 196 197 /* pipe to read credential from stdout of pvfs2-gencred */ 197 198 ret = pipe(filedes); 199 if (ret == -1) 200 { 201 return -PVFS_errno_to_error(errno); 202 } 203 /* pipe to read any error messages from stderr of pvfs2-gencred */ 204 ret = pipe(errordes); 198 205 if (ret == -1) 199 206 { … … 210 217 211 218 close(STDERR_FILENO); 219 dup(errordes[1]); 212 220 close(STDOUT_FILENO); 213 221 dup(filedes[1]); … … 245 253 { 246 254 close(filedes[1]); 255 close(errordes[1]); 247 256 ret = -PVFS_errno_to_error(errno); 248 257 } 249 258 else 250 259 { 251 char buf[sizeof(PVFS_credential)+extra_size_PVFS_credential]; 252 ssize_t total = 0; 253 ssize_t cnt; 260 char buf[sizeof(PVFS_credential)+extra_size_PVFS_credential], 261 ebuf[512]; 262 ssize_t total = 0, etotal = 0; 263 ssize_t cnt, ecnt; 254 264 255 265 /* close write end so we get EOF when child exits */ 266 close(errordes[1]); 256 267 close(filedes[1]); 257 268 269 /* read credential */ 258 270 do 259 271 { 260 do cnt = read(filedes[0], buf+total, (sizeof(buf) - total)); 261 while (cnt == -1 && errno == EINTR); 272 do 273 { 274 cnt = read(filedes[0], buf+total, (sizeof(buf) - total)); 275 } while (cnt == -1 && errno == EINTR); 262 276 total += cnt; 263 277 } while (cnt > 0); … … 280 294 ret = PINT_copy_credential(&tmp, cred); 281 295 } 296 else if (WIFEXITED(rc)) 297 { 298 /* error code from pvfs2_gencred */ 299 ret = -PVFS_errno_to_error(WEXITSTATUS(rc)); 300 } 282 301 else 283 302 { 284 /* nlmills: TODO: find a more appropriate error code*/303 /* catch-all error */ 285 304 ret = -PVFS_EINVAL; 286 305 } 306 307 /* read errors and warnings */ 308 do 309 { 310 do 311 { 312 ecnt = read(errordes[0], ebuf+etotal, 313 (sizeof(ebuf) - etotal)); 314 } while (ecnt == -1 && errno == EINTR); 315 etotal += ecnt; 316 } while (ecnt > 0 && etotal < sizeof(ebuf)); 317 /* null terminate */ 318 ebuf[(etotal < sizeof(ebuf)) ? etotal : sizeof(ebuf)] = '\0'; 319 320 /* print errors */ 321 if (etotal > 0) 322 { 323 char gbuf[600]; 324 snprintf(gbuf, sizeof(gbuf), "pvfs2_gencred: %s", ebuf); 325 gossip_err(gbuf); 326 } 287 327 } 288 328 } 289 329 290 330 close(filedes[0]); 331 close(errordes[0]); 291 332 sigaction(SIGCHLD, &oldsa, NULL); 292 333
