Commit f438e58b authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Remove struct norns_cred

Application credentials are no longer needed given that
authentication of administrator clients is now enforced
with appropriate permissions to the communication socket.
parent 6693f8c1
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -46,13 +46,6 @@ extern "C" {
/* will be able to successfully use these)                                */
/**************************************************************************/

/* Process credentials */
struct norns_cred {
    // TODO: to be completed, but at least...
    pid_t cr_pid;    /* PID of the process */
    gid_t cr_gid;    /* GID of the process */
};

/* Descriptor for a storage backend */
typedef struct {
    const char* b_nsid;     /* namespace ID for this backend (e.g. nvm01, tmpfs02, ...) */
@@ -92,32 +85,32 @@ void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts,
norns_error_t norns_ping() __THROW;

/* Send a command to the daemon (e.g. stop accepting new tasks) */
//norns_error_t norns_command(struct norns_cred* auth);
//norns_error_t norns_command();

/* Register a batch job into the system */
norns_error_t norns_register_job(struct norns_cred* auth, uint32_t jobid, norns_job_t* job) __THROW;
norns_error_t norns_register_job(uint32_t jobid, norns_job_t* job) __THROW;

/* Update an existing batch job */
/* XXX: At the moment this invalidates all registered processes for this job */
norns_error_t norns_update_job(struct norns_cred* auth, uint32_t jobid, norns_job_t* job) __THROW;
norns_error_t norns_update_job(uint32_t jobid, norns_job_t* job) __THROW;

/* Remove a batch job from the system */
norns_error_t norns_unregister_job(struct norns_cred* auth, uint32_t jobid) __THROW;
norns_error_t norns_unregister_job(uint32_t jobid) __THROW;

/* Add a process to a registered batch job */
norns_error_t norns_add_process(struct norns_cred* auth, uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;
norns_error_t norns_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;

/* Remove a process from a registered batch job */
norns_error_t norns_remove_process(struct norns_cred* auth, uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;
norns_error_t norns_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;

/* Register a backend in the local norns server */
norns_error_t norns_register_backend(struct norns_cred* auth, norns_backend_t* backend) __THROW;
norns_error_t norns_register_backend(norns_backend_t* backend) __THROW;

/* Update an existing backend in the local norns server */
norns_error_t norns_register_backend(struct norns_cred* auth, norns_backend_t* backend) __THROW;
norns_error_t norns_register_backend(norns_backend_t* backend) __THROW;

/* Unregister a backend from the local norns server */
norns_error_t norns_unregister_backend(struct norns_cred* auth, const char* prefix) __THROW;
norns_error_t norns_unregister_backend(const char* prefix) __THROW;

/* Return a string describing the error number */
char* norns_strerror(norns_error_t errnum) __THROW;
+11 −18
Original line number Diff line number Diff line
@@ -119,13 +119,12 @@ send_ping_request() {
}

norns_error_t
send_job_request(norns_rpc_type_t type, struct norns_cred* auth, 
                 uint32_t jobid, norns_job_t* job) {
send_job_request(norns_rpc_type_t type, uint32_t jobid, norns_job_t* job) {

    int res;
    norns_response_t resp;

    if((res = send_request(type, &resp, auth, jobid, job)) 
    if((res = send_request(type, &resp, jobid, job)) 
            != NORNS_SUCCESS) {
        return res;
    }
@@ -139,13 +138,13 @@ send_job_request(norns_rpc_type_t type, struct norns_cred* auth,


norns_error_t
send_process_request(norns_rpc_type_t type, struct norns_cred* auth, 
                     uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
send_process_request(norns_rpc_type_t type, uint32_t jobid, 
                     uid_t uid, gid_t gid, pid_t pid) {

    int res;
    norns_response_t resp;

    if((res = send_request(type, &resp, auth, jobid, uid, gid, pid)) 
    if((res = send_request(type, &resp, jobid, uid, gid, pid)) 
            != NORNS_SUCCESS) {
        return res;
    }
@@ -158,13 +157,13 @@ send_process_request(norns_rpc_type_t type, struct norns_cred* auth,
}

norns_error_t
send_backend_request(norns_rpc_type_t type, struct norns_cred* auth, 
                     const char* nsid, norns_backend_t* backend) {
send_backend_request(norns_rpc_type_t type, const char* nsid, 
                     norns_backend_t* backend) {

    int res;
    norns_response_t resp;

    if((res = send_request(type, &resp, auth, nsid, backend)) 
    if((res = send_request(type, &resp, nsid, backend)) 
            != NORNS_SUCCESS) {
        return res;
    }
@@ -225,14 +224,12 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
        case NORNS_JOB_UPDATE:
        case NORNS_JOB_UNREGISTER:
        {
            const struct norns_cred* auth = 
                va_arg(ap, const struct norns_cred*);
            const uint32_t jobid =
                va_arg(ap, const uint32_t);
            const norns_job_t* job =
                va_arg(ap, const norns_job_t*);

            if((res = pack_to_buffer(type, &req_buf, auth, jobid, job)) 
            if((res = pack_to_buffer(type, &req_buf, jobid, job)) 
                    != NORNS_SUCCESS) {
                return res;
            }
@@ -243,8 +240,6 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
        case NORNS_PROCESS_ADD:
        case NORNS_PROCESS_REMOVE:
        {
            const struct norns_cred* auth =
                va_arg(ap, const struct norns_cred*);
            const uint32_t jobid =
                va_arg(ap, const uint32_t);
            const uid_t uid =
@@ -254,7 +249,7 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
            const pid_t pid =
                va_arg(ap, const pid_t);

            if((res = pack_to_buffer(type, &req_buf, auth, jobid, uid, gid, pid)) 
            if((res = pack_to_buffer(type, &req_buf, jobid, uid, gid, pid)) 
                    != NORNS_SUCCESS) {
                return res;
            }
@@ -266,14 +261,12 @@ send_request(norns_rpc_type_t type, norns_response_t* resp, ...) {
        case NORNS_BACKEND_UPDATE:
        case NORNS_BACKEND_UNREGISTER:
        {
            const struct norns_cred* auth =
                va_arg(ap, const struct norns_cred*);
            const char* const prefix =
                va_arg(ap, const char* const);
            const norns_backend_t* backend = 
                va_arg(ap, const norns_backend_t*);

            if((res = pack_to_buffer(type, &req_buf, auth, prefix, backend)) 
            if((res = pack_to_buffer(type, &req_buf, prefix, backend)) 
                    != NORNS_SUCCESS) {
                return res;
            }
+6 −6
Original line number Diff line number Diff line
@@ -34,12 +34,12 @@

norns_error_t send_submit_request(norns_iotask_t* task);
norns_error_t send_status_request(norns_iotask_t* task, norns_stat_t* stats);
norns_error_t send_job_request(norns_rpc_type_t type, struct norns_cred* auth, 
                     uint32_t jobid, norns_job_t* job);
norns_error_t send_process_request(norns_rpc_type_t type, struct norns_cred* auth, 
                         uint32_t jobid, uid_t uid, gid_t gid, pid_t pid);
norns_error_t send_backend_request(norns_rpc_type_t type, struct norns_cred* auth, 
                     const char* nsid, norns_backend_t* backend);
norns_error_t send_job_request(norns_rpc_type_t type, uint32_t jobid, 
                               norns_job_t* job);
norns_error_t send_process_request(norns_rpc_type_t type, uint32_t jobid, 
                                   uid_t uid, gid_t gid, pid_t pid);
norns_error_t send_backend_request(norns_rpc_type_t type, const char* nsid, 
                                   norns_backend_t* backend);
norns_error_t send_ping_request();

#pragma GCC visibility pop
+20 −40
Original line number Diff line number Diff line
@@ -49,88 +49,68 @@ norns_ping() {

/* Register and describe a batch job */
int 
norns_register_job(struct norns_cred* auth, uint32_t jobid, 
                   norns_job_t* job) {
norns_register_job(uint32_t jobid, norns_job_t* job) {

    if(auth == NULL || !validate_job(job)) {
    if(!validate_job(job)) {
        return NORNS_EBADARGS;
    }

    return send_job_request(NORNS_JOB_REGISTER, auth, jobid, job);
    return send_job_request(NORNS_JOB_REGISTER, jobid, job);
}

/* Update an existing batch job */
int 
norns_update_job(struct norns_cred* auth, uint32_t jobid, 
                 norns_job_t* job) {
norns_update_job(uint32_t jobid, norns_job_t* job) {

    if(auth == NULL || !validate_job(job)) {
    if(!validate_job(job)) {
        return NORNS_EBADARGS;
    }

    return send_job_request(NORNS_JOB_UPDATE, auth, jobid, job);
    return send_job_request(NORNS_JOB_UPDATE, jobid, job);
}


/* Remove a batch job from the system */
int norns_unregister_job(struct norns_cred* auth, uint32_t jobid) {

    if(auth == NULL) {
        return NORNS_EBADARGS;
    }

    return send_job_request(NORNS_JOB_UNREGISTER, auth, jobid, NULL);
int norns_unregister_job(uint32_t jobid) {
    return send_job_request(NORNS_JOB_UNREGISTER, jobid, NULL);
}


/* Add a process to a registered batch job */
int 
norns_add_process(struct norns_cred* auth, uint32_t jobid, uid_t uid,
                  gid_t gid, pid_t pid) {

    if(auth == NULL) {
        return NORNS_EBADARGS;
    }

    return send_process_request(NORNS_PROCESS_ADD, auth, jobid, uid, gid, pid);
norns_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
    return send_process_request(NORNS_PROCESS_ADD, jobid, uid, gid, pid);
}


/* Remove a process from a registered batch job */
int 
norns_remove_process(struct norns_cred* auth, uint32_t jobid, uid_t uid,
                     gid_t gid, pid_t pid) {

    if(auth == NULL) {
        return NORNS_EBADARGS;
    }

    return send_process_request(NORNS_PROCESS_REMOVE, auth, jobid, 
                                uid, gid, pid);
norns_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
    return send_process_request(NORNS_PROCESS_REMOVE, jobid, uid, gid, pid);
}

/* Register a backend in the local norns server */
int 
norns_register_backend(struct norns_cred* auth, norns_backend_t* backend) {
norns_register_backend(norns_backend_t* backend) {

    if(auth == NULL || !validate_backend(backend)) {
    if(!validate_backend(backend)) {
        return NORNS_EBADARGS;
    }

    const char* const nsid = backend->b_nsid;

    return send_backend_request(NORNS_BACKEND_REGISTER, auth, nsid, backend);
    return send_backend_request(NORNS_BACKEND_REGISTER, nsid, backend);
}

/* Unregister a backend from the local norns server */
int 
norns_unregister_backend(struct norns_cred* auth, const char* nsid) {
norns_unregister_backend(const char* nsid) {

    if(auth == NULL || nsid == NULL) {
    if(nsid == NULL) {
        return NORNS_EBADARGS;
    }

    return send_backend_request(NORNS_BACKEND_UNREGISTER, auth, nsid, NULL);
    return send_backend_request(NORNS_BACKEND_UNREGISTER, nsid, NULL);
}

norns_backend_t 
+0 −10
Original line number Diff line number Diff line
@@ -159,12 +159,9 @@ build_request_msg(norns_rpc_type_t type, va_list ap) {
        case NORNS_JOB_UPDATE:
        case NORNS_JOB_UNREGISTER:
        {
            const struct norns_cred* auth = va_arg(ap, struct norns_cred*);
            const uint32_t jobid = va_arg(ap, uint32_t);
            const norns_job_t* job = va_arg(ap, norns_job_t*);

            (void) auth;

            if((req_msg->type = encode_request_type(type)) < 0) {
                goto cleanup_on_error;
            }
@@ -187,14 +184,11 @@ build_request_msg(norns_rpc_type_t type, va_list ap) {
        case NORNS_PROCESS_ADD:
        case NORNS_PROCESS_REMOVE:
        {
            const struct norns_cred* auth = va_arg(ap, struct norns_cred*);
            const uint32_t jobid = va_arg(ap, uint32_t);
            const uid_t uid = va_arg(ap, uid_t);
            const gid_t gid = va_arg(ap, gid_t);
            const pid_t pid = va_arg(ap, pid_t);

            (void) auth;

            if((req_msg->type = encode_request_type(type)) < 0) {
                goto cleanup_on_error;
            }
@@ -218,15 +212,11 @@ build_request_msg(norns_rpc_type_t type, va_list ap) {
        case NORNS_BACKEND_UPDATE:
        case NORNS_BACKEND_UNREGISTER:
        {
            const struct norns_cred* auth =
                va_arg(ap, const struct norns_cred*);
            const char* const nsid =
                va_arg(ap, const char* const);
            const norns_backend_t* backend = 
                va_arg(ap, const norns_backend_t*);

            (void) auth;

            if((req_msg->type = encode_request_type(type)) < 0) {
                goto cleanup_on_error;
            }
Loading