]> jfr.im git - irc.git/blob - software/!RELEASES/ircservices/achurch.org/services/lists/ircservices-coding/2008/003324.html
RELEASE -> !RELEASE
[irc.git] / software / !RELEASES / ircservices / achurch.org / services / lists / ircservices-coding / 2008 / 003324.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
2 <HTML>
3 <HEAD>
4 <TITLE> [IRCServices Coding] Migrating Modules to 5.1...
5 </TITLE>
6 <LINK REL="Index" HREF="index.html" >
7 <LINK REL="made" HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Migrating%20Modules%20to%205.1...&In-Reply-To=48AB0288.7060600%40webspace.ms">
8 <META NAME="robots" CONTENT="index,nofollow">
9 <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
10 <LINK REL="Previous" HREF="003323.html">
11 <LINK REL="Next" HREF="003325.html">
12 </HEAD>
13 <BODY BGCOLOR="#ffffff">
14 <H1>[IRCServices Coding] Migrating Modules to 5.1...</H1>
15 <B>Andrew Church</B>
16 <A HREF="mailto:ircservices-coding%40ircservices.za.net?Subject=%5BIRCServices%20Coding%5D%20Migrating%20Modules%20to%205.1...&In-Reply-To=48AB0288.7060600%40webspace.ms"
17 TITLE="[IRCServices Coding] Migrating Modules to 5.1...">achurch at achurch.org
18 </A><BR>
19 <I>Wed Aug 20 11:20:26 PDT 2008</I>
20 <P><UL>
21 <LI>Previous message: <A HREF="003323.html">[IRCServices Coding] Migrating Modules to 5.1...
22 </A></li>
23 <LI>Next message: <A HREF="003325.html">[IRCServices Coding] [IRCServices] akick not setting channel ban
24 </A></li>
25 <LI> <B>Messages sorted by:</B>
26 <a href="date.html#3324">[ date ]</a>
27 <a href="thread.html#3324">[ thread ]</a>
28 <a href="subject.html#3324">[ subject ]</a>
29 <a href="author.html#3324">[ author ]</a>
30 </LI>
31 </UL>
32 <HR>
33 <!--beginarticle-->
34 <PRE>To extract from a Password structure (assuming the source password buffer
35 is declared as &quot;Password source_password&quot;):
36
37 char password_buffer[PASSMAX];
38 char *cipher;
39 memcpy(password_buffer, source_password.password, PASSMAX);
40 cipher = strdup(source_password.cipher);
41
42 To copy into a Password structure (assuming the target password buffer is
43 declared as &quot;Password target_password&quot; and the data to be copied is in
44 &quot;password_buffer&quot; and &quot;cipher&quot; variables as above):
45
46 Password temp_password;
47 init_password(&amp;temp_password);
48 memcpy(temp_password.password, password_buffer, PASSMAX);
49 temp_password.cipher = cipher;
50 copy_password(&amp;target_password, &amp;temp_password);
51 // Don't leave a copy of the password in memory
52 memset(&amp;temp_password, 0, sizeof(temp_password));
53 memset(password_buffer, 0, PASSMAX);
54
55 I actually think I'll add a set_password() function to simplify this, so
56 the above would then become simply:
57
58 set_password(&amp;target_password, password_buffer, cipher);
59 // Don't leave a copy of the password in memory
60 memset(password_buffer, 0, PASSMAX);
61
62 See the &quot;encrypt.h&quot; header file and section 2-9-1 of the technical manual
63 for further details.
64
65 --Andrew Church
66 <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org</A>
67 <A HREF="http://achurch.org/">http://achurch.org/</A>
68
69 &gt;<i>Hy,
70 </I>&gt;<i>
71 </I>&gt;<i>Would that be the right way?:
72 </I>&gt;<i>
73 </I>&gt;<i>copy_password(&amp;ngi-&gt;pass, &amp;passbuf);
74 </I>&gt;<i>strncpy(&amp;passbuf, row[field(MYSQL_FIELD_USERINFO_PASSWORD) ...
75 </I>&gt;<i>
76 </I>&gt;<i>Are there sample codes to use copy_password in the right way?
77 </I>&gt;<i>
78 </I>&gt;<i>Regards.
79 </I>&gt;<i>
80 </I>&gt;<i>
81 </I>&gt;<i>Andrew Church schrieb:
82 </I>&gt;&gt;<i> Passwords are no longer stored as simple strings, since each password
83 </I>&gt;&gt;<i> can be encrypted with a different method (cipher). To save data from
84 </I>&gt;&gt;<i> a Password structure, you need to save both the contents of
85 </I>&gt;&gt;<i> Password.password (as a binary buffer, not a string) and the string
86 </I>&gt;&gt;<i> pointed to by Password.cipher (which may be NULL). To restore a
87 </I>&gt;&gt;<i> Password structure, fill in the password and cipher fields in a
88 </I>&gt;&gt;<i> temporary variable, then use copy_password() to copy the data to the
89 </I>&gt;&gt;<i> destination Password structure.
90 </I>&gt;&gt;<i>
91 </I>&gt;&gt;<i> --Andrew Church
92 </I>&gt;&gt;<i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">achurch at achurch.org</A>
93 </I>&gt;&gt;<i> <A HREF="http://achurch.org/">http://achurch.org/</A>
94 </I>&gt;&gt;<i>
95 </I>&gt;&gt;<i>
96 </I>&gt;&gt;&gt;<i> Hy,
97 </I>&gt;&gt;&gt;<i>
98 </I>&gt;&gt;&gt;<i> I'm migrating my old modules for ircservices-5.1.11, but I've seen that
99 </I>&gt;&gt;&gt;<i> there were many changes in the nickgroupinfo_ struct.
100 </I>&gt;&gt;&gt;<i> &quot;char pass[PASSMAX];&quot; were replaced by &quot;Password pass;&quot;, so my module
101 </I>&gt;&gt;&gt;<i> won't compile anymore:
102 </I>&gt;&gt;&gt;<i>
103 </I>&gt;&gt;&gt;<i> modules/nickserv/dbsynch.c: In function `copy_data':
104 </I>&gt;&gt;&gt;<i> modules/nickserv/dbsynch.c:83: error: incompatible type for argument 1
105 </I>&gt;&gt;&gt;<i> of `__builtin_strncpy'
106 </I>&gt;&gt;&gt;<i>
107 </I>&gt;&gt;&gt;<i>
108 </I>&gt;&gt;&gt;<i> Line of this code:
109 </I>&gt;&gt;&gt;<i>
110 </I>&gt;&gt;&gt;<i> static void copy_data(MYSQL_ROW row, unsigned long *lengths, NickInfo
111 </I>&gt;&gt;&gt;<i> *ni, NickGroupInfo *ngi) {
112 </I>&gt;&gt;&gt;<i> char temp[100];
113 </I>&gt;&gt;&gt;<i> strncpy(ngi-&gt;pass, row[field(MYSQL_FIELD_USERINFO_PASSWORD)], PASSMAX &lt;
114 </I>&gt;&gt;&gt;<i> lengths[field(MYSQL_FIELD_USERINFO_PASSWORD)] ? PASSMAX :
115 </I>&gt;&gt;&gt;<i> lengths[field(MYSQL_FIELD_USERINFO_PASSWORD)] + 1);
116 </I>&gt;&gt;&gt;<i> ....
117 </I>&gt;&gt;&gt;<i>
118 </I>&gt;&gt;&gt;<i> When I replace &quot;ngi-&gt;pass&quot; by &quot;&amp;ngi-&gt;pass&quot; there's only a warning left,
119 </I>&gt;&gt;&gt;<i> but by running this function copy_data my services crashes.
120 </I>&gt;&gt;&gt;<i>
121 </I>&gt;&gt;&gt;<i> Any Ideas?
122 </I>&gt;&gt;&gt;<i> Regards.
123 </I>&gt;&gt;&gt;<i> ------------------------------------------------------------------
124 </I>&gt;&gt;&gt;<i> To unsubscribe or change your subscription options, visit:
125 </I>&gt;&gt;&gt;<i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding</A>
126 </I>&gt;&gt;&gt;<i>
127 </I>&gt;&gt;&gt;<i> ------------------------------------------------------------------------
128 </I>&gt;&gt;&gt;<i>
129 </I>&gt;&gt;&gt;<i> ------------------------------------------------------------------
130 </I>&gt;&gt;&gt;<i> To unsubscribe or change your subscription options, visit:
131 </I>&gt;&gt;&gt;<i> <A HREF="http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding">http://lists.ircservices.za.net/mailman/listinfo/ircservices-coding</A>
132 </I>&gt;<i>
133 </I></PRE>
134
135
136 <!--endarticle-->
137 <HR>
138 <P><UL>
139 <!--threads-->
140 <LI>Previous message: <A HREF="003323.html">[IRCServices Coding] Migrating Modules to 5.1...
141 </A></li>
142 <LI>Next message: <A HREF="003325.html">[IRCServices Coding] [IRCServices] akick not setting channel ban
143 </A></li>
144 <LI> <B>Messages sorted by:</B>
145 <a href="date.html#3324">[ date ]</a>
146 <a href="thread.html#3324">[ thread ]</a>
147 <a href="subject.html#3324">[ subject ]</a>
148 <a href="author.html#3324">[ author ]</a>
149 </LI>
150 </UL>
151
152 </body></html>