00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifdef COMPILER_LICENSING
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <lmsgi.h>
00041
00042 #include <invent.h>
00043 #include <sys/sysmp.h>
00044
00045 LM_CODE(code, ENCRYPTION_CODE_1, ENCRYPTION_CODE_2, VENDOR_KEY1,
00046 VENDOR_KEY2, VENDOR_KEY3, VENDOR_KEY4, VENDOR_KEY5);
00047
00048
00049 #define TRUE 1
00050 #define FALSE 0
00051 #define LINGER_PERIOD 10
00052 #define ALL (-1)
00053 #define ALL_8BIT (ALL & 0xFF)
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 void
00065 get_license( char * feature_name, int soft, int tiers )
00066
00067 {
00068
00069 int err = FALSE;
00070 char * no_licensing;
00071 char * hard_licensing;
00072 char * tier_licensing;
00073 int numCPU;
00074 int archCPU;
00075 char *p;
00076 inventory_t *inv;
00077 int systemNumCPU = 0;
00078 int systemArchCPU;
00079
00080 no_licensing = getenv("COMPILER_LICENSING");
00081 if (no_licensing != NULL) {
00082 return;
00083 }
00084
00085 hard_licensing = getenv("HARD_LICENSING");
00086 if (hard_licensing != NULL) {
00087 soft = FALSE;
00088 }
00089
00090 tier_licensing = getenv("TIER_LICENSING");
00091 if (tier_licensing != NULL) {
00092 tiers = FALSE;
00093 }
00094
00095 if (license_init(&code,"sgifd",B_TRUE) < 0) {
00096 err = TRUE;
00097 }
00098
00099
00100 license_set_attr(LMSGI_NO_SUCH_FEATURE, NULL);
00101
00102
00103 license_set_attr(LM_A_LINGER, (LM_A_VAL_TYPE) LINGER_PERIOD);
00104
00105
00106
00107
00108
00109
00110
00111
00112 if (license_chk_out(&code,
00113 feature_name,
00114 "7.000"
00115 )) {
00116 err = TRUE;
00117 fprintf(stderr,"%s\n", license_errstr());
00118 fprintf(stderr,"\n");
00119 }
00120
00121 if ((tiers) && (err == FALSE)) {
00122 CONFIG *conf = lc_auth_data(get_job(), feature_name);
00123 if (conf == NULL) {
00124 err = TRUE;
00125 fprintf(stderr,"%s\n", license_errstr());
00126 fprintf(stderr,"\n");
00127 } else {
00128 if ((conf->users == 0) && (conf->lc_vendor_def != NULL) &&
00129 (strcmp(conf->lc_vendor_def, "") != 0)) {
00130
00131
00132
00133
00134 p = conf->lc_vendor_def;
00135 while ( ((*p) != '\0') && (((*p) < '0') || ((*p) > '9')) )
00136 p++;
00137 numCPU = atoi(p);
00138
00139 while ((inv = getinvent()) != NULL) {
00140 if ((inv->inv_class == INV_PROCESSOR) &&
00141 (inv->inv_type == INV_CPUBOARD)) {
00142 if ((inv->inv_unit & ALL_8BIT) == ALL_8BIT) {
00143 systemNumCPU = sysmp(MP_NPROCS);
00144 systemArchCPU = inv->inv_state;
00145 } else {
00146 systemNumCPU = inv->inv_unit;
00147 systemArchCPU = inv->inv_state;
00148 }
00149 }
00150 }
00151
00152 if ((numCPU >= systemNumCPU)) {
00153 err = FALSE;
00154 } else if ( numCPU == 0 ) {
00155 err = FALSE;
00156 } else {
00157 err = TRUE;
00158 fprintf(stderr, " This product's license is for %d CPU's; Your system has %d CPU's\n", numCPU, systemNumCPU );
00159 fprintf(stderr,"\n");
00160 }
00161 }
00162 }
00163 }
00164
00165 if (err) {
00166 fprintf(stderr," This product (%s) requires a license password. \n", feature_name);
00167 fprintf(stderr," For license installation and trouble shooting \n");
00168 fprintf(stderr," information visit the web page: \n");
00169 fprintf(stderr,"\n");
00170 fprintf(stderr," http://www.sgi.com/Support/Licensing/install_docs.html \n");
00171 fprintf(stderr,"\n");
00172 fprintf(stderr," To obtain a Permanent license (proof of purchase\n");
00173 fprintf(stderr," required) or an Evaluation license please\n");
00174 fprintf(stderr," visit our license request web page: \n");
00175 fprintf(stderr,"\n");
00176 #if 0
00177 fprintf(stderr," Internal SGI Users refer to:\n");
00178 fprintf(stderr," http://wwclass.csd.sgi.com/swl-internal/beta_lice.html\n");
00179 fprintf(stderr," Otherwise:\n");
00180 #endif
00181 fprintf(stderr," http://www.sgi.com/Products/license.html \n");
00182 fprintf(stderr,"\n");
00183 fprintf(stderr," or send a blank email message to: \n");
00184 fprintf(stderr,"\n");
00185 fprintf(stderr," license@sgi.com \n");
00186 fprintf(stderr,"\n");
00187 fprintf(stderr," In North America, Silicon Graphics' customers may request \n");
00188 fprintf(stderr," Permanent licenses by sending a facsimile to: \n");
00189 fprintf(stderr,"\n");
00190 fprintf(stderr," (415) 390-0537 \n");
00191 fprintf(stderr,"\n");
00192 fprintf(stderr," or by calling our technical support hotline \n");
00193 fprintf(stderr,"\n");
00194 fprintf(stderr," 1-800-800-4SGI \n");
00195 fprintf(stderr,"\n");
00196 fprintf(stderr," If you are Outside of North America or you are not a Silicon \n");
00197 fprintf(stderr," Graphics support customer then contact your local support provider. \n");
00198 fprintf(stderr,"\n");
00199 #if 0
00200 fprintf(stderr," Note: Permanent Licenses require verification of entitlement \n");
00201 fprintf(stderr," (i.e., Proof-of-Purchase). \n");
00202 fprintf(stderr," \n");
00203 #endif
00204
00205
00206 if (!soft)
00207 exit(-1);
00208 }
00209 }
00210
00211 #endif