°¢ ÇÁ·Î¼¼½º´Â ½ÇÁ¦ »ç¿ëÀڽĺ°¹øÈ£¿Í ±×·ì½Äº°¹øÈ£¿Íµµ ¿¬°üµÈ´Ù.
À̰͵éÀº ±× ÇÁ·Î¼¼½º¸¦ È£ÃâÇÑ ½ÇÁ¦ »ç¿ëÀÚ¿Í, ±× »ç¿ëÀÚ°¡ ¼ÓÇÑ
±×·ìÀÇ ½Äº°¹øÈ£µéÀÌ´Ù. ´õ Áß¿äÇÑ °ÍÀº À¯È¿ »ç¿ëÀڽĺ°¹øÈ£¿Í
À¯È¿±×·ì½Äº°¹øÈ£Àε¥, À̰͵éÀº ¾î¶² »ç¿ëÀÚ°¡ ÇÑ ÈÀÏÀ» Á¢±ÙÇÒ ¼ö
ÀÖ´Â ÁöÀÇ ¿©ºÎ¸¦ °áÁ¤Çϴµ¥ »ç¿ëµÈ´Ù.
´ëºÎºÐÀÇ °æ¿ì¿¡ À¯È¿»ç¿ëÀÚ ½Äº° ¹øÈ£¿Í ½ÇÁ¦»ç¿ëÀÚ ½Äº°¹øÈ£´Â °°´Ù.
ÇÁ·Î½º·¦ ÈÀÏÀÇ set-user-id ºñÆ®°¡ 1 À̸é, ±× ÇÁ·Î±×·¥ÀÌ
exec ·Î È£ÃâµÉ ¶§, ±×ÇÁ·Î¼¼½º ÀÇ À¯È¿ »ç¿ëÀڽĺ°¹øÈ£´Â
±× ÇÁ·Î¼¼½º¸¦ ½ÃÀÛ½ÃŲ ½ÇÁ¦»ç¿ëÀÚ°¡ ¾Æ´Ï¶ó ÇÁ·Î±×·¥ ÈÀÏÀÇ
¼ÒÀ¯ÀÚ°¡ µÈ´Ù. ÇÁ·Î¼¼½º¿Í ¿¬°üµÈ »ç¿ëÀÚ¿Í ±×·ìÀÇ ½Äº°¹øÈ£¸¦
¾ò´Âµ¥ ¾²ÀÌ´Â ½Ã½ºÅÛÈ£ÃâÀÌ ¸î°¡Áö ÀÖ´Ù.
int uid, euid, gid, egid;
/* get real user-id */
uid = getuid();
/* get effective user-id */
euid = geteuid();
/* get real group-id */
gid = getgid();
/* get effective group-id */
egid = getegid();
À¯È¿»ç¿ëÀÚ¿Í ±×·ìÀÇ ½Äº°¹øÈ£¸¦ ÁöÁ¤ÇÒ ¶§¿¡´Â ´ÙÀ½ÀÇ µÎ°¡Áö È£ÃâÀÌ
À¯¿ëÇÏ´Ù.
int status, newuid, newgid;
.
.
/* set effective user-id */
status = setuid(newuid);
/* set effective group-id */
status = setgid(newgid);
µÎ ·çƾÀÇ º¹±Í°ªÀÌ 0 ÀÌ¸é ¼öÇàÀÇ ¼º°øÀ», 1 ÀÌ¸é ½ÇÆи¦ ³ªÅ¸³½´Ù.
|