Ejemplo n.º 1
0
FILE *
email_developers_open(const char *subject)
{
	char *tmp;
	FILE *mailer;

	/* 
	** According to the docs, if CONDOR_DEVELOPERS is not
	** in the config file, it defaults to UW.  If it is "NONE", 
	** nothing should be emailed.
	*/
    tmp = param ("CONDOR_DEVELOPERS");
    if (tmp == NULL) {
		/* we strdup here since we always call free below */
#ifdef NO_PHONE_HOME
		tmp = strdup("NONE");
#else
        tmp = strdup("*****@*****.**");
#endif
    }

    if (strcasecmp (tmp, "NONE") == 0) {
        free (tmp);
        return NULL;
    }

	mailer = email_open(tmp,subject);		

	/* Don't forget to free tmp! */
	free(tmp);
	return mailer;
}
Ejemplo n.º 2
0
FILE *
email_user_open_id( ClassAd *jobAd, int cluster, int proc, 
					const char *subject )
{
	FILE* fp = NULL;
    char* email_addr = NULL;
    char* email_full_addr = NULL;
    int notification = NOTIFY_COMPLETE; // default

	ASSERT(jobAd);

		// TODO make this all work properly w/ shouldSend()
    jobAd->LookupInteger( ATTR_JOB_NOTIFICATION, notification );
    switch( notification ) {
	case NOTIFY_NEVER:
		dprintf( D_FULLDEBUG, 
				 "The owner of job %d.%d doesn't want email.\n",
				 cluster, proc );
		return NULL;
		break;
	case NOTIFY_COMPLETE:
			// Should this get email or not?
	case NOTIFY_ERROR:
	case NOTIFY_ALWAYS:
		break;
	default:
		dprintf( D_ALWAYS, 
				 "Condor Job %d.%d has unrecognized notification of %d\n",
				 cluster, proc, notification );
		break;
    }

    /*
	  Job may have an email address to whom the notification
	  message should go.  This info is in the classad.
    */
    if( ! jobAd->LookupString(ATTR_NOTIFY_USER, &email_addr) ) {
			// no email address specified in the job ad; try owner 
		if( ! jobAd->LookupString(ATTR_OWNER, &email_addr) ) {
				// we're screwed, give up.
			return NULL;
		}
	}
		// make sure we've got a valid address with a domain
	email_full_addr = email_check_domain( email_addr, jobAd );
	fp = email_open( email_full_addr, subject );
	free( email_addr );
	free( email_full_addr );
	return fp;
}
Ejemplo n.º 3
0
void
NotifyUser( char *buf, PROC *proc )
{
        FILE *mailer;
        char subject[ BUFSIZ ];	

        dprintf(D_FULLDEBUG, "NotifyUser() called.\n");

		sprintf( subject, "Condor Job %d.%d", 
				 proc->id.cluster, proc->id.proc );

		if( ! JobAd ) {
			dprintf( D_ALWAYS, "In NotifyUser() w/ NULL JobAd!\n" );
			return;
		}

			// email HACK for John Bent <*****@*****.**>
			// added by Derek Wright <*****@*****.**> 2005-02-20
		char* email_cc = param( "EMAIL_NOTIFICATION_CC" );
		if( email_cc ) {
			bool allows_cc = true;
			int bool_val;
			if( JobAd->LookupBool(ATTR_ALLOW_NOTIFICATION_CC, bool_val) ) {
				dprintf( D_FULLDEBUG, "Job defined %s to %s\n",
						 ATTR_ALLOW_NOTIFICATION_CC,
						 bool_val ? "TRUE" : "FALSE" );
				allows_cc = (bool)bool_val;
			} else {
				dprintf( D_FULLDEBUG, "%s not defined, assuming TRUE\n",
						 ATTR_ALLOW_NOTIFICATION_CC );
			}
			if( allows_cc ) {
				dprintf( D_FULLDEBUG, "%s is TRUE, sending email to \"%s\"\n",
						 ATTR_ALLOW_NOTIFICATION_CC, email_cc );
				mailer = email_open( email_cc, subject );
				publishNotifyEmail( mailer, buf, proc );
				email_close( mailer );
			} else {
				dprintf( D_FULLDEBUG,
						 "%s is FALSE, not sending email copy\n",
						 ATTR_ALLOW_NOTIFICATION_CC );
			}
			free( email_cc );
			email_cc = NULL;
		}

        /* If user loaded program incorrectly, always send a message. */
        if( MainSymbolExists == TRUE ) {
                switch( proc->notification ) {
                case NOTIFY_NEVER:
                        return;
                case NOTIFY_ALWAYS:
                        break;
                case NOTIFY_COMPLETE:
                        if( proc->status == COMPLETED ) {
                                break;
                        } else {
                                return;
                        }
                case NOTIFY_ERROR:
                        if( (proc->status == COMPLETED) && (WTERMSIG(JobStatus)!= 0) ) {
                                break;
                        } else {
                                return;
                        }
                default:
                        dprintf(D_ALWAYS, "Condor Job %d.%d has a notification of %d\n",
                                        proc->id.cluster, proc->id.proc, proc->notification );
                }
        }

		mailer = email_user_open(JobAd, subject);
        if( mailer == NULL ) {
                dprintf(D_ALWAYS,
                        "Shadow: Cannot notify user( %s, %s, %s )\n",
                        subject, proc->owner, "w"
                );
				return;
        }
		publishNotifyEmail( mailer, buf, proc );
		email_close(mailer);
}
Ejemplo n.º 4
0
FILE *
email_admin_open(const char *subject)
{
	return email_open(NULL,subject);
}