METU Department of Computer Engineering CEng 332 - System Programming and Support Environments Spring 2007-2008 Final (Take Home / Due: Jun 16, 10:00 AM/5 pages) Name: No: Signature: Note: You are not expected to give complete codes in any of the questions. Just provide significant parts of the code. Replace details with simple verbal description, use pseudo-code whenever appropriate. Your code is not expected to work, just describe key parts of programs. Question 1 : (30 points) Assume you have a directory of plugins and each plugin is a shared object file. Your task is to check directory periodically, load plugins added to directory and start their entry functions in threads. Each plugin implements getinfo() and startservice() functions: # define PLUGINPATH "/ var / run / final332 / plugin /" struct p l i n f o { char name [40]; // name of the plugin char d e s c [40]; // description int p o r t ; // TCP / IP port that plugin is attacched to char p a t h [MAX PATH]; // path of the plugin ( set by the main thread ) p t h r e a d t t i d ; // thread running the plugin ( set by the main thread ) } ; void g e t i n f o ( struct p l i n f o *); void s t a r t s e r v i c e ( void *); Assume plugins will never be deleted explicitly from the directory. a)give code of the main thread of the program that: Checks PLUGINPATH directory for new plugins once in 10 seconds Load shared object with dl library Call getinfo() of the plugin to get plinfo structure from plugin and insert into a data structure (use pseudo code for insertion etc.). Create a new thread with startservice() of the plugin, set tid field of the plinfo. b)give code of a function unloadplugin(char *name) that: finds the name from the plugin information. destroys the thread plugin is running on deletes the shared object file from plugin directory make sure that main thread do not reload it before you delete it This function is to be called explicitly on demand. c)give code of a sample plugin named ECHO. It: listens on tcp port 56789 creates a new thread on each connection for each connection reads a line with at most 1024 bytes, and write the same line back at the same socket Plugin should implement getinfo() and startservice() functions. 1
Question 2 : (25+10 points) Assume you want to define an TCP/IP based service for the following functions described in pseudo code: int c r e a t e t a b l e ( s t r i n g t a b l e n a m e ); int d e l e t e t a b l e ( s t r i n g t a b l e n a m e ); struct p a i r { s t r i n g key ; s t r i n g v a l u e ; }; int s e t v a l u e ( s t r i n g tablename, struct p a i r k e y a n d v a l u e ); s t r i n g g e t v a l u e ( s t r i n g tablename, s t r i n g key ); l i s t o f s t r u c t p a i r g e t a l l v a l u e s ( s t r i n g t a b l e n a m e ); You can think of a scenario where programs access to tables of key-value pairs of strings. Keys per table is unique and if it exists in a table, a string value can be retrieved or set. a)give XDR definition (to be used for rpcgen utility) of this service description for SUN/RPC (also known as ONC/RPC). You can use any program number. Give a linked list of struct pair records for the last function. Only provide the.x file. b)assume your service is an XML/RPC service. Provide the XML structures of the call and return messages for 5 functions. You can use arbitrary sample values for parameters and return values. Assume last function returns an array with 2 struct pair. Assume no error occured. c)(+10 points bonus) Assume your service is a Corba service. Provide IDL for the service. 2
Question 3 : (25 points) You are given the following SSL certificate file: -----BEGIN CERTIFICATE----- MIIExzCCA6+gAwIBAgIJAOoOAMg1mMTcMA0GCSqGSIb3DQEBBQUAMIGdMQswCQYD VQQGEwJUWjESMBAGA1UECBMJS29yYmF0dXJhMQ4wDAYDVQQHEwVCYWJpbDEbMBkG A1UEChMSQ0VuZyAzMzIgU29sdXRpb25zMQ4wDAYDVQQLEwVGaW5hbDEcMBoGA1UE AxMTU3lzdGVtcyBQcm9ncmFtbWluZzEfMB0GCSqGSIb3DQEJARYQb251ckBtZXR1 LmVkdS50cjAeFw0wODA2MTExMzU0MjlaFw0wODA3MTExMzU0MjlaMIGdMQswCQYD VQQGEwJUWjESMBAGA1UECBMJS29yYmF0dXJhMQ4wDAYDVQQHEwVCYWJpbDEbMBkG A1UEChMSQ0VuZyAzMzIgU29sdXRpb25zMQ4wDAYDVQQLEwVGaW5hbDEcMBoGA1UE AxMTU3lzdGVtcyBQcm9ncmFtbWluZzEfMB0GCSqGSIb3DQEJARYQb251ckBtZXR1 LmVkdS50cjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALaBdRKWdpM0 WVFw1w9H6afe+oY/GVmBgfhUBxtIE/qMJ//2Ak32tMr48t7y/OowGryCUkGrsiVU FB66nK+fSm1ElO0c0fkbYUlqDcz8YxcwJnU7jkVAHrwDlmonKeIAHwSrex2baitd VeM572PxIhoJwmd42WU6qa/fjjB5/uISnC+MUVvwlNbNJBiTYrkQRy36uJr7x1jM hjvnky1cxp4w09dttz8mlkd6emvvraqqrxngdwjdnuntu7pkssd9dejotaahpxl/ Olieo92u7yrEQ5j8g2POqXgUM3MjRRvbQ/w5MjOWFuf80Uft3w0t6BS1jfeo2rzO JuUdYne9loUCAwEAAaOCAQYwggECMB0GA1UdDgQWBBR6oRTVX0X8moaofJo69Glu A9pHzjCB0gYDVR0jBIHKMIHHgBR6oRTVX0X8moaofJo69GluA9pHzqGBo6SBoDCB ntelmakga1uebhmcvfoxejaqbgnvbagtcutvcmjhdhvyyteomawga1uebxmfqmfi awwxgzazbgnvbaoteknfbmcgmzmyifnvbhv0aw9uczeomawga1uecxmfrmluywwx HDAaBgNVBAMTE1N5c3RlbXMgUHJvZ3JhbW1pbmcxHzAdBgkqhkiG9w0BCQEWEG9u dxjabwv0ds5lzhuudhkccqdqdgdinzje3dambgnvhrmebtadaqh/ma0gcsqgsib3 DQEBBQUAA4IBAQCp+TDWI4ks0aG4bBvv+Ikl0UaMpnM43nd7qcRz3HT5XQe+o2Rr 1LhURHwPxqnvo+r0qmD4KqRX9xhjIWsHsLAcKtD/MgyzIDm8+rOMU0kNWcGibheW qwnblf8cy2zfwx8tx451+cq5n16ht11tn1zq8ihi5qgg5y6paaaq3e6sdt9hjsva b4hbsnylr5zdd/wnbfwt10tct0wufskxhwukuvyejmqyciu3/mb8tepqvx45u6jl vcekh2mmfq9sacoav5amfowk+5sazxc3shw4ftwllan8t58qvicsog4tuglambem PE1qSvvuTq2nM3QZygiVLur1WHI1q5hzZQTy -----END CERTIFICATE----- and the following private key file: -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAtoF1EpZ2kzRZUXDXD0fpp976hj8ZWYGB+FQHG0gT+own//YC Tfa0yvjy3vL86jAavIJSQauyJVQUHrqcr59KbUSU7RzR+RthSWoNzPxjFzAmdTuO RUAevAOWaicp4gAfBKt7HZtqK11V4znvY/EiGgnCZ3jZZTqpr9+OMHn+4hKcL4xR W/CU1s0kGJNiuRBHLfq4mvvHWMyGO+crLUJenhbT11O3PyYsoPoQxVWsCqqtc0Z3 AkM1Se27s+RJJ30N6M5NoAc/Ev86WJ6j3a7vKsRDmPyDY86peBQzcyNFG9tD/Dky M5YW5/zRR+3fDS3oFLWN96javM4m5R1id72WhQIDAQABAoIBAB5Xx68fdPdkbLUt nzpc0owofl7bfstyzlkmv2g5yhin1nipfhiyo9bdlr4ekcihduqageykz0ofhxlu 09gfE7C3BkulzwMrmjEqgMDj9VWVm89B55V746A+uHNNr5jzjDSqjf2OKUisa+sr ZrGnFZReqwOpA/vglPW4pVtJ7SaIya7d6L62YnysMSVlpLbDlLylQw3i9izwQdsv axnivpqxeu45muegavmw6bakz1namr6c7yh4vartxbqr7lzedtwigkpb8blr6s1u FQmCbBEhMq366C1z+5ZCOZP49T2F/4l9pAlvdWuvKYPzDPmTeuuZzIOdWfxMRVfX nkuqqaecgyea2oo/hka9iqt0nw3+nbcvisgaeiqvfcnaufjei7sofzicho9hyuo4 9/nFb/ks7dz6DMFr0ehJzBlxJcGstbsZ5XBLqL3aRdL9EfwAXpoAqfIqH0ltIhCt VFWhQn8fAfq0Ic+pPt/TVtYeCDi+pErU2pYVeywg1Xawon+K3OJAfYUCgYEA12py zomdbtxndntmfqmjsl07qn3stxl6ihh+xtfu1bbdcp6jd2wh1nw6kzj3gzr1uwwi sbxrlz3kqqunc6a9szg2atxbvz6zxkzevohoabkw22bsdo49ugihzvmyiiwigorx zxklfgo2ckvbolzozbtfqzlnbw5vhux1dn5bhqecgyeal7gqgtv+ovodnd8dxg6z LEvU9w7YsQTV4WnKl/kV18o+Z8qcZQXlv+J82dUQPIlahkNd8uEhhFOjFIJCFpT3 Bsck0699k2p/P+3eIExb/ID4Pwuu/a1mXV7Ku+SHPm4nQKKqP+RyPwDg3mU5yVTh TMS933k8ubAa2HyWFelUq7UCgYBd9CeuCBaJk4EoC9ObpZVRHijCj3m2ijdet6BT FFouVuqBvz88zvl8KEz/Q+BwcWjZ36JdfYfO8dbSOZCwaIEXUs9kg/XFG+B4pd1F 2hMrlAXMG8/2xYMolBkjxOkqYl7GK6eEwXUOt47TAsDk/57OlvaDSkHjtjSZWseT UrlIAQKBgQCfmL2pTsb5NA17goLD3G54ehQMIvIX2CaSXeEjUDX7hBJqQui/q/FC u9dh9pbrgzkueo3lwhtedeueust6sqhzcor9h3opw+yktieo/xab0fmck4q0fedg 54SDsxchKiypiQqRNChZZINwT2FS0VS+J/BuKzTOGgzGf94HYTdk+A== -----END RSA PRIVATE KEY----- a)what is the issuer, validity information of this self signed certificate and how many of bits used in RSA? Use openssl command. Only give the required information. b)assume you use this files are available on your filesystem and you use them to have an SSL connection. Give the required calls to set your private key, set your certificate, get peers certificate and verify peers certificate in openssl library. Only provide the calls, no error handling. Assume connection is established and ssl and ssl ctx variables are ready and set. 3
c)somebody used this certificate and sent you an encrypted mail. Use your private key to decrypt the following message: MIME-Version: 1.0 Content-Disposition: attachment; filename="smime.p7m" Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m" Content-Transfer-Encoding: base64 MIICLQYJKoZIhvcNAQcDoIICHjCCAhoCAQAxggHIMIIBxAIBADCBqzCBnTELMAkG A1UEBhMCVFoxEjAQBgNVBAgTCUtvcmJhdHVyYTEOMAwGA1UEBxMFQmFiaWwxGzAZ BgNVBAoTEkNFbmcgMzMyIFNvbHV0aW9uczEOMAwGA1UECxMFRmluYWwxHDAaBgNV BAMTE1N5c3RlbXMgUHJvZ3JhbW1pbmcxHzAdBgkqhkiG9w0BCQEWEG9udXJAbWV0 ds5lzhuudhiccqdqdgdinzje3danbgkqhkig9w0baqefaascaqcmj6d4joqb0vkq ianxr9vbsrgjwdtmm0xlrr2gtsa538wzpvuttehs3i/v/1j8z0o6lsw9zb8hnyzh qrqidom4prneiaw9ufyz1qxdvez4cwgekgz4d9a6bv0uxdpe7xfcvfext5hnmu+e 7rsft4fL59JPikr6NVdXHrD7X3MFNd777uTo+TXy1MDNbiKCHIZT1YlSNbrYMyly 4V4MimZrNmR4tLznW3k3EDIaJAKg4rHAR0mBOktQVex+zP6hgZbDSaMlcNhmYPjV ZDkwDaHGLwi+Q+tX6lOJg7YZoXcrE/PCyawpYkqK6s3bwQD7VKwRiLdG6f31/5rG Rn9Gl5lYMEkGCSqGSIb3DQEHATAaBggqhkiG9w0DAjAOAgIAoAQIwQODqEjC1+CA IHk24TMKBt1ha79DHbXtuNIPQC30qbLMwuMYYohkKM8x Use smime subcommand of the openssl utility. provide the command line you used and the resulting decrypted text. 4
Question 4 : (25 pts) Assume I need the following information (tags) in a course report XML file: course name code root element Name of the course 7 digit integer code of the course instructors assistants List of staff information, that are instructors of the course. 1 or more instructors. List of staff information, that are teaching assistants of the course. 0 or more assistants. staff Staff information, The name and pid of the staff. students List of 1 or more student tags consisting of name, studentid and grades tags. name Any string studentid A string of the form dddddd-d grades Grades of a a student including midterm, final tags containing a single integer in range 0-120, homeworks tag containing list of 2 homework tags, overall tag containing a real value in range 0-120, letter tag containing one of the strings AA, BA, BB,..., FF, I, NA A sample course.xml file will look like: < course > <name > Systems Programming </ name > <code > 5710332 </ code > < intructors > <staff ><name >Onur S e h i t o g l u </ name > <pid > 117951 </ pid > </ staff > </ instructors > < assistants > <staff ><name > Cuneyt Mertayak </ name > <pid > 187120 </ pid > </ staff > </ assistants > < students > < student ><name > F a h r e t t i n C u r e k l i b a t u r </ name > < studentid >123423-2 </ studentid > < grades >< midterm >100 </ midterm ><final >88 </ final > < homeworks >< homework >86 </ homework > < homework >91 </ homework ></ homeworks > < overall > 82.2123 </ overall > < letter >AA</ letter > </ grades > </ student > < student ><name >Fatma G i r i k </ name > < studentid >123498-2 </ studentid > < grades >< midterm >95 </ midterm ><final >98 </ final > < homeworks >< homework >96 </ homework > < homework >51 </ homework ></ homeworks > < overall > 88.2123 </ overall > < letter >AA</ letter > </ grades > </ student > </ students > </ course > a)give DTD for this document type. b)give XSD for this document type. Put all restrictions given in the descriptions. 5